Posts

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...

Huffman coding algoritnm

Huffman coding algorithm:- Huffman coding .  Huffman  Algorithm was developed by David  Huffman  in 1951. This is a technique which is used in a data compression or it can be said that it is a  coding  technique which is used for  encoding  data. Huffman  is widely  used  in all the mainstream compression formats that you might encounter - from GZIP, PKZIP (winzip etc) and BZIP2, to image formats such as JPEG and PNG. algorithm:-      Huffman(c)      {          n = |c|   //where mod of c is set of character          make a min heap 'Q' with c       [O(n)]          for i in range n-1          // allocated a new node z           z.left = x = extract - min(Q)          z.rigth=y= extract - min(Q)         ...

Insertion sort using java

What is insertion sort in data structure? Insertion Sort  Algorithm.  Insertion sort  is the  sorting  mechanism where the  sorted  array is built having one item at a time. The array elements are compared with each other sequentially and then arranged simultaneously in some particular order.   Algorithm   Now we have a bigger picture of how this sorting technique works, so we can derive simple    steps by which we can achieve insertion sort. Step 1 − If it is the first element, it is already sorted. return 1; Step 2 − Pick next element Step 3 − Compare with all elements in the sorted sub-list Step 4 − Shift all the elements in the sorted sub-list that is greater than the value to be sorted Step 5 − Insert the value Step 6 − Repeat until list is sorted    Let's see a  simple java program  to  sort  an array using  insertion sort  algorithm.    import java.util.*; ...