运行demo.m即可得到示例运行结果。
1 加密解密函数
function ciphertext = AES_encryption(plaintext,password)
%AES加密函数,要求输入明文比特流plaintext长度为128*n,密码比特流password长度为128
%要求比特流为行向量,例如 plaintext = randi([0,1],1,128);password = randi([0,1],1,128);
function plaintext = AES_decryption(ciphertext,password)
%AES解密函数,要求输入密文比特流ciphertext长度为128*n,密码比特流password长度为128
%要求比特流为行向量,例如 ciphertext = randi([0,1],1,128);password = randi([0,1],1,128);
2 运行示例
密文或密码的一个比特的错误会导致解密得到的几乎一半的比特发生错误,说明AES加解密性能较好。