Wednesday, February 29, 2012

[Assembly] [MIPS] Hello World

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Hello World written in Assembly (MIPS) language. Since I am new with this, there is very significant differences when I use the other language. That is because Assembly is a low-level programming language. With this language, I will play more with the register shifting. Now, with this program, for beginning, it will say the "Hello World!" phrase. Okay, that's all I can say. Thank you for reading ^^!



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











Wednesday, February 15, 2012

[C++] Frequency Analysis (Alphabet)

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Frequency Analysis for Alphabet. The source code written in C++. The source code can count how many N-Graph does a text have. It also the percentage of each N-Graph. Example:

> Input with Digraph (2-Graph):
"One day, I got a chicken lemper. However, when I ate it, it has no chicken meat.Where did the chicken go?"

> Output:

ON => 1 (2.5%)
ED => 1 (2.5%)
AY => 1 (2.5%)
IG => 1 (2.5%)
OT => 1 (2.5%)
AC => 1 (2.5%)
HI => 1 (2.5%)
CK => 1 (2.5%)
EN => 1 (2.5%)
LE => 1 (2.5%)
MP => 1 (2.5%)
ER => 1 (2.5%)
HO => 1 (2.5%)
WE => 1 (2.5%)
VE => 1 (2.5%)
RW => 1 (2.5%)
HE => 3 (7.5%)
NI => 1 (2.5%)
AT => 1 (2.5%)
EI => 1 (2.5%)
TI => 1 (2.5%)
TH => 1 (2.5%)
AS => 1 (2.5%)
NO => 1 (2.5%)
CH => 2 (5%)
IC => 2 (5%)
KE => 2 (5%)
NM => 1 (2.5%)
EA => 1 (2.5%)
TW => 1 (2.5%)
RE => 1 (2.5%)
DI => 1 (2.5%)
DT => 1 (2.5%)
NG => 1 (2.5%)
O? => 1 (2.5%)

As you can see, there is '?' there. That will ensure if there is some letters left which is not multiplied by N, then it will append '?' character. Okay, that's all I can say. Thank you for reading ^^!












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)





Wednesday, February 1, 2012

[C++] Caesar Cipher (ASCII)

          Hello, Reader ^^! Back again with source code ^^! This time the source code is Caesar Cipher for ASCII. How it works it is still same with the Alphabet version. The only differences are this time it is not limited to alphabet anymore, but it is ASCII. Plus, the effective key is increased to 256 keys. Plus, with that, the formula for encryption is:

En(x) = (x + n) mod 256

While the formula for decryption is:

Dn(x) = (x - n) mod 256

For example, I use "HeLLo WoRlD!". I encrypt it with key = 122. It will be rotated into "ÂßÆÆéšÑéÌæ¾›". Okay, that's all I can say ^^! Thank you for reading ^^!





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