A script language of time-sharing scheduling coroutine in single thread
This is a library function for AES encryption and decryption.
aes = Import('aes');
aes.aes(data, key, bits, op);
Input:
data
– a string value and its length can be divided by 16
.key
– a string value for data
encryption and decryption.bits
– an integer value of the key
bit length. key
’s bit length must be equal to or greater than bits
. It supports these value: 128
, 192
, 256
.
op
– a string value to indicate function to encrypt or decrypt. It only has two values: encode
and decode
.Return value:
Error:
Example:
aes = Import('aes');
sys = Import('sys');
str = Import('str');
text = 'This is an aes test, note length';
sys.print('text length: '+str.strlen(text));
key = 'this is a secret';
cipher = aes.aes(text, key, 128, 'encode');
sys.print(cipher);
text = aes.aes(cipher, key, 128, 'decode');
sys.print(text);
The output is:
text length: 32
l???<??J? ?H?D???j?8?!??B#?8
This is an aes test, note length