Posts

Showing posts from September, 2020

PlayFairCipher algorytham

Image
 Playfair is one of the popular cryptographic software security algorithms. This technique encrypts pairs of letters at a time and generates more secure encrypted text compare to  the simple substitution cipher like Caesar. Implementation of playfaircipher:- package com.clg.PlayFair; import java.util.Scanner; public class PlayFairCipher { static char[][] Matrix = new char[5][5];   // A 5*5 matrix of letter based on a keywords static String Alphabats = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; static String cipher = ""; static String plain = ""; public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the plainText "); String plainText = sc.nextLine(); System.out.println("Enter the Key "); String key = sc.nextLine(); String encrypted = Encrypt(plainText, key);  //Encrypt method return to plain text to cipher text  System.out.println("Encrypted Massage"); Syste...

Caesar Cipher Algo

Image
Algorithm  of  Caesar Cipher Caesar Cipher  Technique is the simple and easy method of  encryption  technique. It is simple type of substitution  cipher . Each letter of plain text is replaced by a letter with some fixed number of positions down with alphabet. package clg.Cypto.assignment; import java.util.Scanner; public class CaesarCipher { // Encrypts text using shift public static StringBuffer encrypt(String text, int shift) { StringBuffer result = new StringBuffer(); for (int i = 0; i < text.length(); i++) { if (Character.isUpperCase(text.charAt(i))) { char ch = (char) (((int) text.charAt(i) + shift - 65) % 26 + 65); result.append(ch); } else { char ch = (char) (((int) text.charAt(i) + shift - 97) % 26 + 97); result.append(ch); } } return result; } // Decrypts cipher using shift public static StringBuffer decrypt(String cipher, int shift) { StringBuffer result = new StringBuffer(); for (int...