blob: 8a985079c1ba6202d8542ed477c82cacf9255a96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { AES_ECB } from '@openpgp/asmcrypto.js/dist_es8/aes/ecb';
/**
* Javascript AES implementation.
* This is used as fallback if the native Crypto APIs are not available.
*/
function aes(length) {
const C = function(key) {
const aesECB = new AES_ECB(key);
this.encrypt = function(block) {
return aesECB.encrypt(block);
};
this.decrypt = function(block) {
return aesECB.decrypt(block);
};
};
C.blockSize = C.prototype.blockSize = 16;
C.keySize = C.prototype.keySize = length / 8;
return C;
}
export default aes;
|