例子:
function main() {
var aes = new AES();
var key = aes.genKey();
console.log('key:' + key);
var encodedData = aes.encrypt('你好,世界!', key);
console.log('encodedData:' + encodedData);
var decodedData = aes.decrypt(encodedData, key);
console.log('decodedData:' + decodedData);
}
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mode | string | 选填 | 工作模式,默认为'AES',可以取值:'AES/ECB/PKCS5Padding'等。 |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| len | integer | 选填 | 长度,默认为128 |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| data | string | 必填 | 待编码的数据 |
| key | string | 必填 | 密钥 |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| data | string | 必填 | 编码后的数据 |
| key | string | 必填 | 密钥 |