Friday, March 9, 2012

[C++] ECB (Electronic Code Book)

          Hello, Reader ^^! Back again with source code. This time is is ECB (Electronic Code Book) which is made using C++. Encryption using ECB is separating plaintext bit into blocks (key). After that, each block each encrypted with the block key. When the plaintext's length is not divideable by the key's length, pad it with all 0s or all 1s or 101010... In this example, the Encryption Block used is a simple xor. You can define your own Encryption Block. Now, let's me demonstrate a bit:

plain text (in bit) : 0101111111010101
key : 01101
Encryption Block = a xor b

Now, splitting them into 5 blocks (based on key's length): 01011|11111|01010|1
The last part length is not 5, so let's padding it with 0 bits : 10000






Plaintext(in bits)01011111110101010000
Key per block01011010110101101011
Encryption Block = a xor b 00000101000000111011


The result of encryption is 00000101000000111011
Now, in this one I made, to be able both the key and the plaintext readable, I also pad the key until it is dividable by 8.

Okay, that's all I can say. Thank you for reading ^^!



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





3 comments: