@tonappchain/adnl
Version:
ADNL TypeScript implementation
41 lines • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDecipheriv = exports.createCipheriv = exports.Decipher = exports.Cipher = void 0;
const aes_js_1 = require("aes-js");
class CipherBase {
constructor(key, iv) {
this.cipher = new aes_js_1.ModeOfOperation.ctr(key, new aes_js_1.Counter(iv));
}
final() {
return new Uint8Array([]);
}
}
class Cipher extends CipherBase {
constructor(key, iv) {
super(key, iv);
}
update(data) {
const result = this.cipher.encrypt(data);
return result;
}
}
exports.Cipher = Cipher;
class Decipher extends Cipher {
constructor(key, iv) {
super(key, iv);
}
update(data) {
const result = this.cipher.decrypt(data);
return result;
}
}
exports.Decipher = Decipher;
const createCipheriv = (_algo, key, iv) => {
return new Cipher(key, iv);
};
exports.createCipheriv = createCipheriv;
const createDecipheriv = (_algo, key, iv) => {
return new Decipher(key, iv);
};
exports.createDecipheriv = createDecipheriv;
//# sourceMappingURL=aes.js.map