Showing posts with label vigenere. Show all posts
Showing posts with label vigenere. Show all posts

Monday, February 6, 2012

[Java] Vigenère Cipher (ASCII)

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Vigenère Cipher for ASCII. The source code written in Java, translated from C++ version. It is a bit different than the Alphabet version. This time the non-alphabet are also encrypted (for the alphabet version, non-alphabets are ignored). Okay, let me explain abit again but with ASCII version.

Just say I have plaintext "Hello World!". I want to encrypt it using key "KEY". If encrypt it using Vigenère Cipher, here will be happens:


Plaintext
H
E
L
L
O
W
O
R
L
D
!
Ciphertext
K
E
Y
K
E
Y
K
E
Y
K
E
Y


The key becomes "KEYKEYKEYKEY". Yup, it is repeated based on the length of the plaintext.


Using the Ci = (P+ Ki ) mod 256 (C is Ciphertext, P is Plaintext, K is Key, i is Index), it will give result :
"³Êå×Ô™ÂÔë×Éš".


For the Auto-Key, it also uses ASCII range. Okay, that's all I can say. Thank you for reading ^^!







Download/View Source Code






Sunday, February 5, 2012

[Java] Vigenère Cipher (Alphabet)

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Vigenère Cipher for Alphabet only. The source code written in Java. Yup, it is translated from C++ into Java ^^. With this type of encryption, the plaintext is encrypted based on key which consists of a keyword. Each letter will be ciphered differently based on the sequence of its letter on plaintext and the key. Let's take an example.

Just say I have plaintext "Hello World!". I want to encrypt it using key "KEY". If encrypt it using Vigenère Cipher, here will be happens:


Plaintext
H
E
L
L
O
W
O
R
L
D
!
Ciphertext
K
E
Y
K
E

Y
K
E
Y
K



The key becomes "KEYKE YKEYK". Yup, it is repeated based on the length of the plaintext.


Using the Ci = (P+ Ki ) mod 26 (C is Ciphertext, P is Plaintext, K is Key, i is Index), it will give result :
"RIJVS GSPVH!"


With that type of encryption, cracking the message using frequency analysis can be prevented.


Now, I also made another variant. It is Auto-Key. Using the example above, the key will be "KEYHE LLOWO", taking some part of the plaintext as key. The result will be "AIDSS HZFHR!". Okay, that's all I can say ^^. Thank you for reading ^^!








Download/View Source Code





Saturday, February 4, 2012

[C++] Vigenère Cipher (ASCII)

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Vigenère Cipher for ASCII. The source code written in C++. It is a bit different than the Alphabet version. This time the non-alphabet are also encrypted (for the alphabet version, non-alphabets are ignored). Okay, let me explain abit again but with ASCII version.

Just say I have plaintext "Hello World!". I want to encrypt it using key "KEY". If encrypt it using Vigenère Cipher, here will be happens:


Plaintext
H
E
L
L
O
W
O
R
L
D
!
Ciphertext
K
E
Y
K
E
Y
K
E
Y
K
E
Y


The key becomes "KEYKEYKEYKEY". Yup, it is repeated based on the length of the plaintext.


Using the Ci = (P+ Ki ) mod 256 (C is Ciphertext, P is Plaintext, K is Key, i is Index), it will give result :
"“Š¥—”y¢”«—‰z".


For the Auto-Key, it also uses ASCII range. Okay, that's all I can say. Thank you for reading ^^!







Download/View Source Code
- Dropbox





Thursday, February 2, 2012

[C++] Vigenère Cipher (Alphabet)

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Vigenère Cipher for Alphabet only. The source code written in C++. With this type of encryption, the plaintext is encrypted based on key which consists of a keyword. Each letter will be ciphered differently based on the sequence of its letter on plaintext and the key. Let's take an example. 

Just say I have plaintext "Hello World!". I want to encrypt it using key "KEY". If encrypt it using Vigenère Cipher, here will be happens:

Plaintext
H
E
L
L
O
W
O
R
L
D
!
Ciphertext
K
E
Y
K
E

Y
K
E
Y
K


The key becomes "KEYKE YKEYK". Yup, it is repeated based on the length of the plaintext.

Using the Ci = (P+ Ki ) mod 26 (C is Ciphertext, P is Plaintext, K is Key, i is Index), it will give result :
"RIJVS GSPVH!"

With that type of encryption, cracking the message using frequency analysis can be prevented.

Now, I also made another variant. It is Auto-Key. Using the example above, the key will be "KEYHE LLOWO", taking some part of the plaintext as key. The result will be "AIDSS HZFHR!". Okay, that's all I can say ^^. Thank you for reading ^^!





Download/View Source Code
- Dropbox
- Dropbox (Repository)