Competition Exam : Knowledge Portal

Civil Services, Banking Jobs, Admission Alerts and Guidance Portal

Wednesday, October 5, 2022

Some more of Jave

===caesarCipher===

import java.util.*; 
class caesarCipher 
public static String encode(String enc, int offset) 
offset = offset % 26 + 26; 
StringBuilder encoded = new StringBuilder(); 
for (char i : enc.toCharArray()) 
if (Character.isLetter(i)) 
if (Character.isUpperCase(i))
{ encoded.append((char) ('A' + (i - 'A' + offset) % 26 )); 
}
else { encoded.append((char) ('a' + (i - 'a' + offset) % 26 ));
 } } else { encoded.append(i); 
 } 
 } 
 return encoded.toString(); 
 } 
 public static String decode(String enc, int offset) 
 { 
 return encode(enc, 26-offset); 
 } 
 public static void main (String[] args) throws java.lang.Exception
 { 
 String msg = "Hello welcome to Security Laboratory"; 
 System.out.println("simulation of Caesar Cipher"); 
 System.out.println("input message : " + msg); 
 System.out.printf( "encoded message : "); 
 System.out.println(caesarCipher.encode(msg, 12)); 
 System.out.printf( "decoded message : "); 
 System.out.println(caesarCipher.decode(caesarCipher.encode(msg, 12), 12)); } }  
 /* stdin: Standard input is empty  
 stdout: simulation of Caesar Cipher  
 input message : Hello welcome to Security Laboratory   
 encoded message : Tqxxa iqxoayq fa Eqogdufk Xmnadmfadk   
 decoded message : Hello welcome to Security Laboratory     
 RESULT: Thus the program was executed and verified successfully.    
*/

=== END===

===caesarCipherInput===

import java.util.*; 
class caesarCipherInput 
public static String encode(String enc, int offset) 
offset = offset % 26 + 26; 
StringBuilder encoded = new StringBuilder(); 
for (char i : enc.toCharArray()) 
if (Character.isLetter(i)) 
if (Character.isUpperCase(i))
{ encoded.append((char) ('A' + (i - 'A' + offset) % 26 )); 
}
else { encoded.append((char) ('a' + (i - 'a' + offset) % 26 ));
 } } else { encoded.append(i); 
 } 
 } 
 return encoded.toString(); 
 } 
 public static String decode(String enc, int offset) 
 { 
 return encode(enc, 26-offset); 
 } 
 public static void main (String[] args) throws java.lang.Exception
 { 
 System.out.println("simulation of Caesar Cipher"); 
 Scanner in = new Scanner (System.in);
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String msg = in.nextLine();
// String msg = "Hello welcome to Security Laboratory"; 
        System.out.println("input message : " + msg); 
 System.out.printf( "encoded message : "); 
 System.out.println(caesarCipher.encode(msg, 12)); 
 System.out.printf( "decoded message : "); 
 System.out.println(caesarCipher.decode(caesarCipher.encode(msg, 12), 12)); } }  
 /* stdin: Standard input is empty  
 stdout: simulation of Caesar Cipher  
 input message : Hello welcome to Security Laboratory   
 encoded message : Tqxxa iqxoayq fa Eqogdufk Xmnadmfadk   
 decoded message : Hello welcome to Security Laboratory     
 RESULT: Thus the program was executed and verified successfully.    
*/

===END===

====CreatingDigitalSignature====

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Scanner;

public class CreatingDigitalSignature {
   public static void main(String args[]) throws Exception {
      //Accepting text from user
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter some text");
      String msg = sc.nextLine();
      
      //Creating KeyPair generator object
      KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("DSA");
      
      //Initializing the key pair generator
      keyPairGen.initialize(2048);
      
      //Generate the pair of keys
      KeyPair pair = keyPairGen.generateKeyPair();
      
      //Getting the private key from the key pair
      PrivateKey privKey = pair.getPrivate();
      
      //Creating a Signature object
      Signature sign = Signature.getInstance("SHA256withDSA");
      
      //Initialize the signature
      sign.initSign(privKey);
      byte[] bytes = "msg".getBytes();
      
      //Adding data to the signature
      sign.update(bytes);
      
      //Calculating the signature
      byte[] signature = sign.sign();
      
      //Printing the signature
      System.out.println("Digital signature for given text: "+new String(signature, "UTF8"));
   }
}

====END=====

=====DecryptionCode===

// Import Java libraries
import java.util.Scanner;
 
public class DecryptionCode {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be decrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        System.out.print("Please enter an integer value between -1 and -6 for decryption key: ");
        int userKey = in.nextInt();
         
        // User error check for key
        while ((userKey > -7) || (userKey < 0)) {
            System.out.print("Your key must be between -1 and -6.\nPlease enter an integer value between -1 and -6: ");
            userKey = in.nextInt();
        }
         
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        int key = userKey;
        char [] chars = message.toCharArray();
        for(char i : chars) {
            i += key; 
            System.out.print(i);
        }
    }
}
===END===

====DecryptionCodeEvenOdd====


// Import Java libraries
import java.util.Scanner;
 
public class DecryptionCodeEvenOdd {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        /*System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         */
        // User error check for key
        /*while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         */
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        //int key = userKey;
        char [] chars = message.toCharArray();
for(char i : chars) {
//System.out.print("First i");
//System.out.print(i);
if ((i ^ 1) == i + 1) {
// Print statement
//System.out.println("Number is Even");
char encout = (char) (i-1);
//System.out.print("Even encout ");
System.out.print(encout);
}
else {
 
// Print statement
//System.out.println("Number is Odd");
char encout = (char) (i-2);
//System.out.print("Odd encout ");
System.out.print(encout);
}
i += 1;
//System.out.print("Second i");
  // System.out.print(i);

        }
    }
}

====END===

=====Digital_Signature_GeeksforGeeks====

// Java implementation for Generating
// and verifying the digital signature
  
package java_cryptography;
<dependency>
  <groupId>jakarta.xml.bind</groupId>
  <artifactId>jakarta.xml.bind-api</artifactId>
  <version>4.0.0</version>
</dependency>
<dependency>
  <groupId>com.sun.xml.bind</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>4.0.0</version>
  <scope>runtime</scope>
</dependency>  
// Imports
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.util.Scanner;
  
import javax.xml.bind.DatatypeConverter;
  
public class Digital_Signature_GeeksforGeeks {
  
    // Signing Algorithm
    private static final String
        SIGNING_ALGORITHM
        = "SHA256withRSA";
    private static final String RSA = "RSA";
    private static Scanner sc;
  
    // Function to implement Digital signature
    // using SHA256 and RSA algorithm
    // by passing private key.
    public static byte[] Create_Digital_Signature(
        byte[] input,
        PrivateKey Key)
        throws Exception
    {
        Signature signature
            = Signature.getInstance(
                SIGNING_ALGORITHM);
        signature.initSign(Key);
        signature.update(input);
        return signature.sign();
    }
  
    // Generating the asymmetric key pair
    // using SecureRandom class
    // functions and RSA algorithm.
    public static KeyPair Generate_RSA_KeyPair()
        throws Exception
    {
        SecureRandom secureRandom
            = new SecureRandom();
        KeyPairGenerator keyPairGenerator
            = KeyPairGenerator
                  .getInstance(RSA);
        keyPairGenerator
            .initialize(
                2048, secureRandom);
        return keyPairGenerator
            .generateKeyPair();
    }
  
    // Function for Verification of the
    // digital signature by using the public key
    public static boolean
    Verify_Digital_Signature(
        byte[] input,
        byte[] signatureToVerify,
        PublicKey key)
        throws Exception
    {
        Signature signature
            = Signature.getInstance(
                SIGNING_ALGORITHM);
        signature.initVerify(key);
        signature.update(input);
        return signature
            .verify(signatureToVerify);
    }
  
    // Driver Code
    public static void main(String args[])
        throws Exception
    {
  
        String input
            = "GEEKSFORGEEKS IS A"
              + " COMPUTER SCIENCE PORTAL";
        KeyPair keyPair
            = Generate_RSA_KeyPair();
  
        // Function Call
        byte[] signature
            = Create_Digital_Signature(
                input.getBytes(),
                keyPair.getPrivate());
  
        System.out.println(
            "Signature Value:\n "
            + DatatypeConverter
                  .printHexBinary(signature));
  
        System.out.println(
            "Verification: "
            + Verify_Digital_Signature(
                  input.getBytes(),
                  signature, keyPair.getPublic()));
    }
}

=====END=====

=====IntToChar====

import java.util.*;

class IntToChar {
  public static void main(String[] args) {

    // integer variable to be converted to char
    //int a = 89;
         Scanner in = new Scanner (System.in);
  System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int a = in.nextInt();
    //use typecasting to convert int to char in Java
    char c = (char) a;

    //print the character
    System.out.println(c);

  }
}

====END===

====EncryptionCode====


// Import Java libraries
import java.util.Scanner;
 
public class EncryptionCode {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         
        // User error check for key
        while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        int key = userKey;
        char [] chars = message.toCharArray();
        for(char i : chars) {
            i += key; 
            System.out.print(i);
        }
    }
}

=====END===

====EncryptionCodeEvenOdd=====

// Import Java libraries
import java.util.Scanner;
 
public class EncryptionCodeEvenOdd {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        /*System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         */
        // User error check for key
        /*while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         */
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        //int key = userKey;
        char [] chars = message.toCharArray();
/* int keyno = 1;
System.out.print(keyno);
*/        for(char i : chars) {
// System.out.print(i);
if ((i ^ 1) == i + 1) {
// Print statement
//System.out.println("Number is Even");
char encout = (char) (i+1);
System.out.print(encout);
}
else {
 
// Print statement
//System.out.println("Number is Odd");
char encout = (char) (i+2);
System.out.print(encout);
}
i += 1;
//keyno += 1;
        //    System.out.print(i);

        }
    }
}// 

=======END========

=======EncryptionCodeEvenOdd2==========

Import Java libraries
import java.util.Scanner;
 
public class EncryptionCodeEvenOdd2 {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        /*System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         */
        // User error check for key
        /*while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         */
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        //int key = userKey;
        char [] chars = message.toCharArray();
for(char i : chars) {
//System.out.print("First i");
//System.out.print(i);
if ((i ^ 1) == i + 1) {
// Print statement
//System.out.println("Number is Even");
char encout = (char) (i+1);
//System.out.print("Even encout ");
System.out.print(encout);
}
else {
 
// Print statement
//System.out.println("Number is Odd");
char encout = (char) (i+2);
//System.out.print("Odd encout ");
System.out.print(encout);
}
i += 1;
//System.out.print("Second i");
  // System.out.print(i);

        }
    }
}

=====END======

=====GFG=====


// Java Program to Check if Given Integer is Odd or Even
// Using Bitwise XOR
 
// Importing required classes
import java.util.*;
 
// Main class
public class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
         Scanner in = new Scanner (System.in);
 
        // Declare and initializing integer variable
        //int num = 99;
System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int num = in.nextInt();
        
 
        // Condition Check
        // if number^1 increments by 1 then its even number,
        // else odd
        if ((num ^ 1) == num + 1) {
 
            // Print statement
            System.out.println("Number is Even");
        }
        else {
 
            // Print statement
            System.out.println("Number is Odd");
        }
    }
}

=====END====


===HelloWorld====

class HelloWorld{
public static void main(String args[]){
System.out.println("Hello world!");
}
}

====END====

=====IntToChar=====

import java.util.*;

class IntToChar {
  public static void main(String[] args) {

    // integer variable to be converted to char
    //int a = 89;
         Scanner in = new Scanner (System.in);
  System.out.print("Please give input: ");
        char a = in.next().charAt(0);
    //use typecasting to convert int to char in Java
    // char c = (char) a;
    //print the character
a = (char) (a+2);
    System.out.println(a);

  }
}
=======END=====

===MyFirstProgram====


class MyFirstProgram {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}import java.util.*;  
class UserInputDemo   
{  
public static void main(String[] args)  
{  
Scanner sc= new Scanner(System.in);    //System.in is a standard input stream  
System.out.print("Enter first number- ");  
int a= sc.nextInt();  
System.out.print("Enter second number- ");  
int b= sc.nextInt();  
System.out.print("Enter third number- ");  
int c= sc.nextInt();  
int d=a+b+c;  
System.out.println("Total= " +d);  
}  
}  

======END=======

=====UserStrInputDemo=======

import java.util.*;  
class UserStrInputDemo
{  
public static void main(String[] args)  
{  
Scanner sc= new Scanner(System.in); //System.in is a standard input stream  
System.out.print("Enter a string: ");  
String str= sc.nextLine();              //reads string   
System.out.print("You have entered: "+str);             
}  
}  
Read More

Misc Java Programs

CreatingDigitalSignature.java
--------------------------------------

import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
import java.security.Signature;
import java.util.Scanner;

public class CreatingDigitalSignature {
   public static void main(String args[]) throws Exception {
      //Accepting text from user
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter some text");
      String msg = sc.nextLine();
      
      //Creating KeyPair generator object
      KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("DSA");
      
      //Initializing the key pair generator
      keyPairGen.initialize(2048);
      
      //Generate the pair of keys
      KeyPair pair = keyPairGen.generateKeyPair();
      
      //Getting the private key from the key pair
      PrivateKey privKey = pair.getPrivate();
      
      //Creating a Signature object
      Signature sign = Signature.getInstance("SHA256withDSA");
      
      //Initialize the signature
      sign.initSign(privKey);
      byte[] bytes = "msg".getBytes();
      
      //Adding data to the signature
      sign.update(bytes);
      
      //Calculating the signature
      byte[] signature = sign.sign();
      
      //Printing the signature
      System.out.println("Digital signature for given text: "+new String(signature, "UTF8"));
   }
}

----END---

====EncryptionCodeEvenOdd2====

// Import Java libraries
import java.util.Scanner;
 
public class EncryptionCodeEvenOdd2 {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        /*System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         */
        // User error check for key
        /*while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         */
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        //int key = userKey;
        char [] chars = message.toCharArray();
for(char i : chars) {
//System.out.print("First i");
//System.out.print(i);
if ((i ^ 1) == i + 1) {
// Print statement
//System.out.println("Number is Even");
char encout = (char) (i+1);
//System.out.print("Even encout ");
System.out.print(encout);
}
else {
 
// Print statement
//System.out.println("Number is Odd");
char encout = (char) (i+2);
//System.out.print("Odd encout ");
System.out.print(encout);
}
i += 1;
//System.out.print("Second i");
  // System.out.print(i);

        }
    }
}

====END====

=====DecryptionCodeEvenOdd=======
// Import Java libraries
import java.util.Scanner;
 
public class DecryptionCodeEvenOdd {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        /*System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         */
        // User error check for key
        /*while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         */
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        //int key = userKey;
        char [] chars = message.toCharArray();
for(char i : chars) {
//System.out.print("First i");
//System.out.print(i);
if ((i ^ 1) == i + 1) {
// Print statement
//System.out.println("Number is Even");
char encout = (char) (i-1);
//System.out.print("Even encout ");
System.out.print(encout);
}
else {
 
// Print statement
//System.out.println("Number is Odd");
char encout = (char) (i-2);
//System.out.print("Odd encout ");
System.out.print(encout);
}
i += 1;
//System.out.print("Second i");
  // System.out.print(i);

        }
    }
}
====END===

====EncryptionCodeEvenOdd====
// Import Java libraries
import java.util.Scanner;
 
public class EncryptionCodeEvenOdd {
    public static void main(String[] args) {
        // Create a Scanner object attached to the keyboard
        Scanner in = new Scanner (System.in);
         
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String userMessage = in.nextLine();
 
        /* Integer encryption or description key from user.
         * User must provide the opposite mathematical operation of the original key for description.
         * For example, if encryption was done using key 6, then use -6 to decrypt.
        */
        /*System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int userKey = in.nextInt();
         */
        // User error check for key
        /*while (userKey > 6) {
            System.out.print("Your key must be between 1 and 6.\nPlease enter an integer value between 1 and 6: ");
            userKey = in.nextInt();
        }
         */
        // Modulus from user (THIS IS NOT IN USE)
        // System.out.print("What is the secret secondary key? ");
        // int secondKey = in.nextInt();
                 
        // Encryption or decryption processing
        String message = userMessage;
        //int key = userKey;
        char [] chars = message.toCharArray();
/* int keyno = 1;
System.out.print(keyno);
*/        for(char i : chars) {
// System.out.print(i);
if ((i ^ 1) == i + 1) {
// Print statement
//System.out.println("Number is Even");
char encout = (char) (i+1);
System.out.print(encout);
}
else {
 
// Print statement
//System.out.println("Number is Odd");
char encout = (char) (i+2);
System.out.print(encout);
}
i += 1;
//keyno += 1;
        //    System.out.print(i);

        }
    }
}
=====END=====
====GFG===
// Java Program to Check if Given Integer is Odd or Even
// Using Bitwise XOR
 
// Importing required classes
import java.util.*;
 
// Main class
public class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
         Scanner in = new Scanner (System.in);
 
        // Declare and initializing integer variable
        //int num = 99;
System.out.print("Please enter an integer value between 1 and 6 for encryption key: ");
        int num = in.nextInt();
        
 
        // Condition Check
        // if number^1 increments by 1 then its even number,
        // else odd
        if ((num ^ 1) == num + 1) {
 
            // Print statement
            System.out.println("Number is Even");
        }
        else {
 
            // Print statement
            System.out.println("Number is Odd");
        }
    }
}

===END===


===caesarCipherInput===
import java.util.*; 
class caesarCipherInput 
public static String encode(String enc, int offset) 
offset = offset % 26 + 26; 
StringBuilder encoded = new StringBuilder(); 
for (char i : enc.toCharArray()) 
if (Character.isLetter(i)) 
if (Character.isUpperCase(i))
{ encoded.append((char) ('A' + (i - 'A' + offset) % 26 )); 
}
else { encoded.append((char) ('a' + (i - 'a' + offset) % 26 ));
 } } else { encoded.append(i); 
 } 
 } 
 return encoded.toString(); 
 } 
 public static String decode(String enc, int offset) 
 { 
 return encode(enc, 26-offset); 
 } 
 public static void main (String[] args) throws java.lang.Exception
 { 
 System.out.println("simulation of Caesar Cipher"); 
 Scanner in = new Scanner (System.in);
        // Plain text message to be encrypted from user
        System.out.print("Please enter something to be encrypted or the encrypted message: ");
        String msg = in.nextLine();
// String msg = "Hello welcome to Security Laboratory"; 
        System.out.println("input message : " + msg); 
 System.out.printf( "encoded message : "); 
 System.out.println(caesarCipher.encode(msg, 12)); 
 System.out.printf( "decoded message : "); 
 System.out.println(caesarCipher.decode(caesarCipher.encode(msg, 12), 12)); } }  
 /* stdin: Standard input is empty  
 stdout: simulation of Caesar Cipher  
 input message : Hello welcome to Security Laboratory   
 encoded message : Tqxxa iqxoayq fa Eqogdufk Xmnadmfadk   
 decoded message : Hello welcome to Security Laboratory     
 RESULT: Thus the program was executed and verified successfully.    
*/

===END===

===PRACTICAL Q===
An Introduction to Optimization- Foundations and Fundamental Algorithms
Niclas Andr´easson, Anton Evgrafov, and Michael Patriksson

install nmap
install snort
install usbpcap
install wireshark

nmap -sVC -O -T4 scanme.nmap.org

---
Spoof MAC

Use SMAC software
----

MD5: certUtil -hashfile <filename> MD5
Windows Defender – Inbound rules - 

Java program file with java extenstion
Compile : ../javasdk/bin/javac filename
Run: java filename

nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53 –script “default or (discovery and safe)” scanme.nmap.org

===END===
Read More

Sunday, April 4, 2021

RAS 2018

I thought RPSC has since been improved but  when I saw the news in Bhaskar app that RAS 2018 interview are going on and will continue till 7th May 2021, I am sure the institution really needs overhaul. 
Aspiring candidates lost many opportunities due to late conduct of examination in anticipation of positive result.
In the time of technological advancement and tech savvy generation, the commission should think about it and brainstorm.
Link of News:  https://dainik-b.in/M9T1RmMAafb 
Read More

Wednesday, April 15, 2020

RAS 2018 MAINS

Courtesy: Dainik Bhaskar, 15.04.2020
Read More

Sunday, June 25, 2017

RAS MAINS RESULT

RPSC has declared the result of RAS MAINS 2016.

Read More
Blog Widget by LinkWithin
©2000-2011 : CompetitionExam.com. Powered by Blogger.

© 2013 Competition Exam : Knowledge Portal, All Rights Reserved.