fork-openpgpjs/src/crypto/cipher/aes.js
BafS 8505924f34 Remove 'user strict'
'use strict' is unnecessary inside modules because module code is always strict mode code. Ref: https://www.ecma-international.org/ecma-262/6.0/#sec-strict-mode-code
2018-02-13 21:26:02 +01:00

29 lines
663 B
JavaScript

/**
* @module crypto/cipher/aes
*/
import asmCrypto from 'asmcrypto-lite';
// TODO use webCrypto or nodeCrypto when possible.
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;
}