Wednesday, July 31, 2019
Computer Security
G53SEC Computer Security Spring 2012/2013 Coursework 1 Name ID : : Arvinth Gunasegaran 005917 09/04/2013 Due date : Introduction/Technique Cryptography is the act or practice of using techniques for secret communication over public communication channels. The purpose of this is to enable the transmission of messages secretly without being understood by third parties. Cryptography is achieved by means of encryption, which is the process of converting normal text to ciphered text using a key, either public or private.The ciphered text is then transmitted to the receiver, who can decrypt it back to normal text using either a public key (symmetric cryptography) or his or her private key (asymmetric cryptography). One of most famous symmetric encryption techniques is the Caesar cipher, or also known as the shift cipher. It is a type of substitution cipher that works by replacing each alphabet in plaintext into a corresponding alphabet some fixed number of positions either to the right or left of the alphabet.The first Caesar cipher shifted all characters to three positions to the right. However, a shift of any other number or to the left is also used. Based on this, the objective of the coursework is to produce a reverse Caesar cipher encryption. The technique works by first choosing a fixed number to shift the ââ¬ËAââ¬â¢ character. Once the letter ââ¬ËAââ¬â¢ is shifted accordingly, the rest of the alphabets are filled in, in reverse. The example below shows a simple case of reverse Caesar with a shift value of 3. A B C D E F G H I J K D C B A Z Y X W V U TIn this case, the number to shift is 3. Hence, the letter ââ¬ËAââ¬â¢ is first shifted 3 places to the right. The rest of the alphabets are then listed in reverse order, which means the letter ââ¬ËAââ¬â¢ is followed by the letter ââ¬ËZââ¬â¢, ââ¬ËYââ¬â¢ and ââ¬ËXââ¬â¢, instead of ââ¬ËBââ¬â¢, ââ¬ËCââ¬â¢, and ââ¬ËDââ¬â¢ like in normal Caesar ciphers. Program Explanation The reverse Caesar cipher is implemented in Java. The first java class file (Reverse. java), handles most of the algorithms needed to implement the cipher. Firstly, a char array of size 26 is created and all the alphabets are stored in it in normal order.Similarly, another empty array of size 26 is created for the purpose of storing the mapped values of each alphabet in the first array after shifting. A scanner is used to get user input for the sentence they wish to encrypt and the number of places to shift. Encrypt Method This is the method that is used to convert the input text to a ciphered text. Firstly, the algorithm below sets the second array created earlier with mapped values of the characters form the first array. int shift=pass%26; //to calculate modulus int count=0+(shift-1); //insert -1 to include the first char for (int a=0; a
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.