Posts

Build REST CRUD APIs with Kotlin, Spring Boot and MyBatis

Image
Hello everyone, today we will learn how to develop REST-style CRUD APIs with Spring Boot, Kotlin, MyBatis, and H2 Database.  You can download the source code from our Github repository. What is MyBatis? MyBatis is a persistence framework with support for custom SQL, stored procedures and advanced mappings. MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map interfaces and Java POJOs (Plain Old Java Objects) to database records. Some of the features of  MyBatis : In memory object filtering Fortifies clustering and simultaneous access by other applications without loss of transaction integrity Query Caching - Built-in support Fortifies disconnected operations Support for Remoting. Distributed Objects. Technologies used : Spring Boot 2.5.4 Spring  5.3.9 MyBatis  Kotlin Gradle After completing this tutorial what we will build?   We will build REST API 

Kotlin - Map with Multiple Keys - Example

Image
Today we will show you how to implement a  Map with Multiple Keys.  Solution 1: Using Kotlin Custom Key Class Solution 2: Using Google's Guava Solution 3: Using Apache Commons Collections  Example 1: Using Kotlin Custom MultiMapKey  Here we created a custom MultiMap Key class, we can use MultiMap as a Key to map a value. object MultiKeyDemo { @JvmStatic fun main(args: Array<String>) { // Declaring the Map val table: MutableMap<MultiMapKey, String> = HashMap() // Declaring the key objects val key1 = MultiMapKey( "raw1" , "col1" ) val key2 = MultiMapKey( "raw1" , "col2" ) val key3 = MultiMapKey( "raw1" , "col3" ) // Putting the values table[key1] = "Java" table[key2] = "Kotlin" table[key3] = "Android" // Getting value by key val value2 = table[key2] println(value2)

Go Language - RSA Encryption And Decryption Example

Image
The RSA algorithm (Rivest-Shamir-Adleman) is a cryptographic algorithm that is used for specific security services or purposes, which enables public-key encryption and is widely used to secure sensitive data, particularly when it is being sent over an insecure network such as the HTTP. A public key is shared publicly, while a private key is secret and must not be shared with anyone. The following illustration highlights how asymmetric cryptography works: Example 1: RSA Encryption and Decryption with OAEP, package main //Required imports for Encryption & Decryption import ( "crypto/rand" "crypto/rsa" "crypto/sha512" "encoding/base64" "fmt" ) func main() { //3072 is the number of bits for RSA bitSize := 3072 //Generate RSA keys privateKey, err := rsa. GenerateKey(rand.Reader, bitSize) if err != nil { panic(err) } publicKey := privateKey.PublicKey //Your secret te

Python RSA Encryption And Decryption Example

Image
The cryptographic technique known as Rivest-Shamir-Adleman, or RSA, is used for certain security services or goals. It allows for public-key encryption and is frequently used to protect sensitive data, especially when it's being transferred over an unreliable network like the HTTP. Whereas a private key is confidential and needs to be kept to yourself, a public key is shared with others.   The following illustration highlights how asymmetric cryptography works:   Example:  RSA Encryption and Decryption with RSA-OAEP Padding from Crypto.PublicKey import RSA from Crypto.Cipher import PKCS1_OAEP import base64   # 2048 is the number of bits for RSA keys = RSA.generate( 2048 ) publicKey = keys.publickey() publicKeyPEM = publicKey.exportKey() print( "\n" ,publicKeyPEM.decode( 'ascii' )) privateKeyPEM = keys.exportKey() print( "\n" ,privateKeyPEM.decode( 'ascii' )) # Your secret text secretMessage = 'This is your secret' #encrypt the messag