Posts

Go Slice - Program to Find Largest & Smallest Element

Image
Example 1: Finding the largest element in a Slice // Go program to find largest number in a Slice package main import "fmt" // Main function func main() { // Let’s define an slice first arr := [] int { 2 , 11 , 22 , 5 , 6 , 3 , 1 , 9 } fmt.Println( "Largest Number:" , LargestNumber(arr)) //Another Example anotherarr := [] int { 144 , 666 , 99 , 677 , 433 , 422 , 255 } fmt.Println( "Largest Number:" , LargestNumber(anotherarr)) } func LargestNumber(arr [] int ) int { var temp int for i := 0 ; i < len(arr); i++ { for j := i + 1 ; j < len(arr); j++ { if arr[i] > arr[j] { temp = arr[i] arr[i] = arr[j] arr[j] = temp } } } return arr[len(arr)- 1 ] } Output: Example 2: Finding the smallest element in a Slice // Go program to find smallest number in a Slice package main import "fmt" // Main function func ma

React Native - Mobile App development - Simple Login Form example

Image
Congratulations! You are standing in the right place! In this article, we will discuss how to create a simple login form on your local system utilizing the React Native framework and Android Studio. We are going to create a  login form like below, First, you must set up your local development environment. You can follow the below link to set up your local environment.   https://www.knowledgefactory.net/2021/01/react-native-environment-setup-create-demo.html After executing the commands mentioned in this link , a folder with a specified name is created with the following contents. Next, we are going to edit the App.js file and write the code to create a login form Start by importing useState , as shown below. The useState function will allow our functional components to be stateful. import React, { useState } from "react" ; Then initialize the state by integrating the following code. const [email, setEmail] = useState( "" ); const [password, setPassword] = useSt

React Native - Environment Setup - Create a new project

Image
In this article, we will discuss how to establish your development environment on our local system utilizing React Native framework and Android Studio to build Android Apps. Recently, I decided to explore and use React Native for developing Android Apps. However, as I was establishing my development environment in my system, I ran into a plethora of challenges. Establishing React Native on my system is challenging and requires attention to an abundance of moving pieces, even if you opt to get a sample app up and running on an emulator. Step 1: Install Node.js   To check if  node.js  is installed on your system, type  node -v  in the terminal. This will help you see the version of  node.js  currently installed on your system. knfdev@ladmin-knf:~$ node -v v12.18.4 If it does not print anything, install node.js on your system. To install node.js, go to the homepage,  https://nodejs.org/en/download/  of node.js, and install the package based on your OS. Based on your OS, install the requ

Go Language - Program to Check Whether a Number is Odd or Even

Image
Hello everyone, today we will learn how to check whether the entered number is even or odd. Even numbers are the numbers that are divisible by 2 and the numbers that are not divisible by 2 are called odd numbers. Here, in this program, we will check whether the number is divisible by 2 or not. If divisible, then it is an even number, and if not then it is an odd number. Example 1: Check Whether the Number is Even or Odd package main import ( "fmt" ) func main() { var number int fmt.Println( "Enter an integer value : " ) _, err := fmt.Scanf( "%d" , &number) if err != nil { fmt.Println(err) } CheckOddOrEven(number) } func CheckOddOrEven(number int ) { //If number is divisible by 2 then it's an even number //else odd number if number% 2 == 0 { fmt.Println( "The entered number " , number, " is Even" ) } else { fmt.Println( "The entered number "

Kotlin- RSA, AES, 3DES Encryption and Decryption with example

Image
Quick Overview - RSA 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 The Cipher Type: RSA/ECB/PKCS1Padding import java.security.spec.PKCS8EncodedKeySpec import javax.crypto.Cipher import java.security.spec.X509EncodedKeySpec import java.io.IOException import java.security.* import java.util.* class RSADemo { var privateKey: PrivateKey var publicKey: PublicKey companion object { // convert String publickey to Key object @Throws (GeneralSecurityException:: class , IOException:: class ) fun loadP