Getters and Setters in Kotlin

Soumak De
Updated on 16-Mar-2022 12:12:45

696 Views

Properties in Kotlin can be declared either as mutable using the "var" keyword or as read-only using the "val" keyword. Both these types of variables can be referred by their respective names after the method declaration.In Kotlin, getter() and setter() methods need not be created explicitly. The Kotlin library provides both of them by default.ExampleIn this example, we will see how to use the getter() and setter() methods in Kotlin.fun main(args: Array) {    // getter()    println("Name is -> " + Address().name)    println("City is -> " + Address().city)    println("State is -> " + Address().state) } class Address ... Read More

Difference Between isNullOrEmpty and isNullOrBlank in Kotlin

Soumak De
Updated on 16-Mar-2022 12:09:22

2K+ Views

Both these functions, isNullOrEmpty and isNullOrBlank, are used in Kotlin whenever it is required to check if a String value is empty or not. Let's check how these two functions are different from each other.isNullOrBlank – It takes whitespaces into account, which means " " is different from "". This function will return True only when the String is declared with no characters in it. It will check whether the value of the String is NULL and it will also check whether the String is blank.isNullOrEmpty() – This function checks whether the string is declared as NULL or whether it ... Read More

IntArray vs Array in Kotlin

Soumak De
Updated on 16-Mar-2022 11:59:20

8K+ Views

In this article, we will take an example to show the difference between IntArray and Arrayin Kotlin.IntArray in KotlinIntArray is a class in Kotlin representing the array of elements. Each instance of this class is represented as an integer array. To the constructor of this class you need to pass the number of elements you need in the array (size).You can instantiate this class as shown below −val myArray = IntArray(8)By default, all the elements of the created array will be initialized to "0".ExampleThe following program creates an array of integers by instantiating the IntArray class −fun main(args: Array) { ... Read More

What Does the Operator Do in Kotlin

Soumak De
Updated on 16-Mar-2022 11:40:59

428 Views

In Kotlin, the "===" operator checks the referential equality of two objects. Any expression "a===b" will evaluate to True if and only if both "a" and "b" point to the same object. That is, both "a" and "b" share the same address.In contrast, we can use the "==" operator to check structural equality which implies that two objects have equivalent content. Basically, "==" is a check for equals().Example: "===" Operator in Kotlinfun main(args: Array) {    var str1 : String = "That's it"    var str2 : String = "It's OK"    var str3 : String = str1   ... Read More

Kotlin Static Methods and Variables

Soumak De
Updated on 16-Mar-2022 11:34:55

8K+ Views

In Java, once a method is declared as "static", it can be used in different classes without creating an object. With static methods, we don't have to create the same boilerplate code for each and every class. Here we will take an example to demonstrate how Kotlin implements static methods.Example – Static Method in Kotlin using Companion ObjectIn order to implement a static method in Kotlin, we will take the help of "companion objects".Companion objects are the singleton objects whose properties and functions are tied to a class but not to the instance of that class. Hence, we can access ... Read More

Procedure of Miller-Rabin Primality Testing

Ginni
Updated on 16-Mar-2022 10:27:34

626 Views

The Miller-Rabin Permality test combines the Fermat test and the Fermat root test in a classic method to find a strong pseudoprime. In this test, it can write n – 1 as the product of an odd number m and a power of 2 −$$\mathrm{n-1=m\, x\, 2^{k}}$$The Fermat test in base a can be composed as −$$\mathrm{a^{n-1}\, =\, a^{m\, x\, 2k}=\left [ a^{m} \right ]^{2k}=\left [ a^{m} \right ]\frac{2^{2}\cdot \cdot \cdot 2}{K\, times}}$$In other words, rather than calculating an−1(mod n) in one step, it can do it in k+1 steps. The advantage of using k + 1 is that each ... Read More

Steps of Key Generation Using RSA Algorithm

Ginni
Updated on 16-Mar-2022 10:21:54

4K+ Views

RSA is a cryptosystem for public-key encryption, and is broadly used for securing responsive information, specifically when being sent over an insecure network including the Internet.In RSA cryptography, both the public and the private keys can encrypt a message; the inverse key from the one used to encrypt a message is used to decrypt it. This attribute is one reason why RSA has develop into the most broadly used asymmetric algorithm. It supports an approach of assuring the confidentiality, integrity, authenticity and non-reputability of digital connection and data storage.RSA need a multiplicative group G =< Z$\mathrm{\phi}$n, *, X > for ... Read More

Steps in RSA for Information Security

Ginni
Updated on 16-Mar-2022 10:03:43

1K+ Views

The RSA algorithm is a public-key signature algorithm founded by Ron Rivest, Adi Shamir, and Leonard Adleman. RSA can also encrypt and decrypt general data to securely exchange information along with managing digital signature verification.The RSA algorithm is based on the complexity contained in the factorization of large numbers. The RSA algorithm depends on the fact that there is no effective method to factor very large numbers. Therefore, deducing an RSA key would take a large amount of time and processing power.RSA algorithm is asymmetric cryptography algorithm as it operate on two different keys such as public key and private ... Read More

How RSA Works

Ginni
Updated on 16-Mar-2022 10:00:28

1K+ Views

The Rivest-Shamir-Adleman (RSA) encryption algorithm is an asymmetric encryption algorithm that is broadly used in several products and services. Asymmetric encryption need a key pair that is mathematically connected to encrypt and decrypt data.A private and public key are generated, with the public key being available to anyone and the private key being a secret known only by the key set creator. With RSA, the private or public key can encrypt the information, while the other key decrypts it. This is the reasons that RSA is the generally used asymmetric encryption algorithm.The choice to encrypt with either the private or ... Read More

What is the RSA Algorithm in Information Security

Ginni
Updated on 16-Mar-2022 09:58:06

2K+ Views

RSA stands for Rivest, Shamir, Adleman. They are the founder of public-key encryption technology, which is a public-key cryptosystem for protected information transmission. It is a standard encryption approach for transmitting responsive information, particularly while transferring data over the internet.The Rivest-Shamir-Adleman (RSA) encryption algorithm is an asymmetric encryption algorithm that is broadly used in some products and services. A private and public key are generated, with the public key being available to anyone and the private key being a private known only by the key set creator.With RSA, the private or public key can encrypt the information, while the different ... Read More

Advertisements