Kriptografi : Program C++ Enkripsi dan Deskripsi
Cryptography is the science and an art to maintain the confidentiality of messages (data or information) in a way to disguise it into a form that can not be understood. The purpose encryption is that the content of the message can not be understood by unauthorized people.
Some basic terminology of cryptography :
1. Plainteks (plaintext or cleartext, meaning the text is clear and understandable): messages are kept confidential.
2. Chiperteks (ciphertext or cryptogram, meaning encrypted text): encoding the message.
3. Enkripsi (encryption atau enchipering): encoding process of the plaintext to chiperteks.
4. Dekripsi (decryption atau dechipering): reversal process of the ciphertext to plain text
5. Algoritma kriptografi (atau chiper):
Example :
plainteks : uang disimpan di balik buku X
chiperteks: j&kloP(d$gkhtpuBn%6^klp..t@8^
Mathematical notation
For example:
C = chiperteks
P = plaintext
then the encryption function E mapping P to C --> E(P) = C, and
decryption function D maps C to P --> D(C) = P
Caesar Cipher
Caesar Cipher is an algorithm by substituting characters with other characters.
Substitution table:
pi : 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
ci : D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
With each letter of the alphabet to encode an integer as follows: A = 0, B = 1, ..., Z = 25, then mathematically caesar cipher to encrypt the plaintext pi become ci with the rules:
ci = E(pi) = (pi + 3) mod 26
and decryption chiperteks ci become pi with rules : pi = D(ci) = (ci – 3) mod 26
To encrypt or description of the program can be made. We are of the friction with the ASCII code of key. In the example rules above, key = 3. In the program we can use the input from the user how many keys.
This function for encryption :
void kriptografi::enkripsi(){
for(int i=0; i<strlen(plain); i++){
chiper[i]=(plain[i]+key)%128;
}
cout<<endl<<endl;
}
Here's to a description :
void kriptografi::deskripsi(){
for (int i=0; i<strlen(chiper); i++){
teks[i]=(chiper[i]-key)%128;
}
}
Complete program to be tried can be downloaded here
Jadilah yang pertama mengomentari
Post a Comment