Encryption Function
Since data that is encrypted must be able to be decrypted, an encryption function must be invertible (one-to-one and entire) over the set of all possible input data. This means each step in the process must also be invertible. One way to accomplish encryption is to use a matrix (with a non-zero determinant). Split the text into several matrices (padding input as necessary). Then apply the transformation matrix to each input matrix and concatenate the result. However, most modern encryption schemes use a combination of transformation matrices and bit twiddling to accomplish encryption.
Encryption in Cryptography
The usefulness of encryption for cryptography is quite obvious. In fact, most of cryptography is centered around encryption and decryption.
AES-128 Encryption and Decryption Function (slightly modified)
I made an AES-128 Encryption/Decryption implementation for my password program. Here’s one that uses the same exact algorithm, but in JavaScript (feel free to look at the source code):
Encryption:
Plaintext: | Password: |
Decryption:
Cyphertext: | Password: |