Skip to main content

Posts

Showing posts from August, 2017

Hill Cipher

                                            Hill cipher encryption-decryption. PSEUDOCODE Encryption To encrypt a message using the Hill Cipher we must first turn our keyword into a key matrix (a 2 x 2 matrix for working with digraphs, a 3 x 3 matrix for working with trigraphs, etc). We also turn the plaintext into digraphs (or trigraphs) and each of these into a column vector. We then perform matrix multiplication modulo the length of the alphabet (i.e. 26) on each vector. These vectors are then converted back into letters to produce the ciphertext. Step 1:  We shall encrypt the plaintext message "short example" using the keyword hill and a 2 x 2 matrix. The first step is to turn the keyword into a matrix. If the keyword was longer than the 4 letters needed, we would only take the first 4 letters, and if it was shorter, we would fill it up with the alphabet...

Polyalphabetic cipher

Polyalphabetic cipher encryption- decryption. PSEDOCODE: Encryption                   Ci=(Ti +Ki)modn Ci - i-th character of the ciphertext Ti - i-th character of the open text Ki - i-th character of the key phrase (if the key phrase is shorter than the open text, which is usual, than the keyphrase is reapeated to math the length of the open text) m - length of the alphabet 1.       To encrypt the open text, we have to sum together the first letters of the open text and key phrase, the second letters, third and so on. 2.       To encrypt the n-th letter of the open text (assume “L“) using the Vigenère square 3.       we find the letter on the horizontal axis of the table and we find n-th letter of the key phase on the vertical axis (assume “T“) 4.        At the intersect...

Playfair cipher

                                                          Playfair cipher encryption-decryption Pseudocode: 1.       First, a plaintext message is split into pairs of two letters (digraphs). If there is an odd number of letters, a Z is added to the last letter. Let us say we want to encrypt the message "Programming". It will be written as - Programming 2.       The rules of encryption are - 3.       If both the letters are in the same column, take the letter below each one (going back to the top if at the bottom) 4.       If both letters are in the same row, take the letter to the right of each one (going back to the left if at the farthest right) 5.       If neither of the preceding two rules is true, fo...

Mono alphabetic cipher

                                               Mono alphabetic cipher encryption-decryption A mono-alphabetic cipher is a type of simple substitution cipher. In this cipher technique, each letter of the plaintext is replaced by another letter in the cipher-text. An example of a mono-alphabetic cipher key follows: Plain Text   >>>   a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z Cipher Text >>>  z  w  x  y  o  p  r  q  a  h  c  b  e  s  u  t  v  f  g  j  l  k  m  n  d  i This key means that any ‘a’ in the plaintext will be replaced by a ...

Caesar cipher

Aim :   Implement Caesar cipher encryption-decryption. Pseudocode: The source text that needs to be encrypted is given in lower case. But if you need to decrypt the text, it should be given in upper case. When it is encrypted, each letter will have its ANSII code increased for three places. When it is decrypted, it will have its code moved toward left. The letter ‘x’ will be translated into ‘A’, the letter ‘y’ is transformed into the letter ‘B’, and the ‘z’ will change into ‘C’. We are keeping this logic very simple so that we can understand the code. Once you get the hang of it, come-up with more complex logic to encrypt and decrypt. The program will handle only English letters and each input text will not be longer that one sentence. At the end of the input sentence, it should have the marker for end ‘.’.  the longest sentence is 1024 letters long. This is some form of protection, which would prevent the user to input the sentence that would over populate size o...