Encrypt Decrypt Crack Save Encrypted
Cryptobox's cipher uses a 16-bit key to transform blocks of 16 bits at a time. To provide better security for long messages, the cipher uses the CBC mode of operation to encrypt the message.
DISCLAIMER: Cryptobox is in no way a secure system. It is designed to allow experimentation with cryptography, and should not be used to protect sensitive data.
To decrypt encrypted text, enter the ciphertext in the right panel, enter the key, and click "Decrypt." The decrypted text will appear in the left panel. If you don't know the key, click "Crack," and Cryptobox will brute-force the decryption, trying each key on the ciphertext. The Key field will show the progress, and the key if it is found. Note that if the ciphertext is damaged, decryption will be impossible.
To save the ciphertext for later retrieval, click "Save Encrypted." The ciphertext will be saved on the server, and you will be redirected to a URL that uniquely describes that ciphertext. You can then bookmark the URL, send it to a friend, or do anything else you can do with a URL.
#!/usr/bin/perl # Generate S-boxes from pi use strict; my (@sbox, @rsbox); # Digits of PI from http://www.joyofpi.com/pi.html my @PI = (1415926535,8979323846,2643383279,5028841971,6939937510); my $PI = pop @PI; for (0..15) { # Select four bits my $b; do { $b = $PI & 0xF; $PI >>= 4; $PI = pop @PI if $PI == 0; } while (exists $rsbox[$b]); $sbox[$_] = $b; $rsbox[$b] = $_; } print 'var sbox = [', join(',', @sbox), "];\n"; print 'var rsbox = [', join(',', @rsbox), "];\n";
The use of known constants in cryptographic functions is called a "Nothing up my sleeve number," which is used to put at ease any fears that the S-boxes were engineered to have weaknesses that I could exploit. This does not mean that they don't have weaknesses, mind you, just that I didn't intend any. Running the script gives us our S-boxes:
var sbox = [6,14,10,0,7,13,9,1,3,15,11,2,8,12,5,4]; var rsbox = [3,7,11,8,15,14,0,4,12,6,2,10,13,5,1,9];
Rsbox is the reverse of the S-box, used during decryption to reverse the process. To transform a number, it is "looked up" in the sbox array, and the number in that position is substituted. For example, the S-box transformation of 7 is 1. Remember that arrays count from zero.
DuhES uses the CBC mode of operation, which uses an Initialization Vector (abbreviated IV) in addition to the key. At the beginning of the encryption process, the IV is XORed with a block's worth of plaintext, and run through the encryption. This result becomes the IV for the next round, and the process is repeated until no more plaintext remains.
Decryption flips the process on its head, first decrypting a block of ciphertext, then XORing the result with the IV to produce the first block of plaintext. The first block of ciphertext is then used as the IV for the next stage, and so on.
There is a problem, however, with this approach. Since a block cipher can only encrypt or decrypt a block at a time, if the message is not long enough to fill an entire block at the end, the message must be padded to fill a whole block. DuhES pads the final block with null bytes if necessary (which, since the block size is only 16 bits, will add at most one byte). On decryption, null bytes are removed from the output. This has a side effect of making the encryption/decryption process not suitable for binary data, but since all we're doing is encrypting text, it's not a concern.