fork-openpgpjs/src/crypto/cipher/aes.js
2018-01-30 18:36:38 +01:00

30 lines
627 B
JavaScript

/**
* @module crypto/cipher/aes
*/
'use strict';
import asmCrypto from 'asmcrypto-lite';
export default function aes(length) {
var c = function(key) {
this.key = Uint8Array.from(key);
this.encrypt = function(block) {
block = Uint8Array.from(block);
return Array.from(asmCrypto.AES_ECB.encrypt(block, this.key, false));
};
this.decrypt = function(block) {
block = Uint8Array.from(block);
return Array.from(asmCrypto.AES_ECB.decrypt(block, this.key, false));
};
};
c.blockSize = c.prototype.blockSize = 16;
c.keySize = c.prototype.keySize = length / 8;
return c;
}