@li0ard/kuznyechik
Version:
Kuznyechik cipher implementation in pure TypeScript
23 lines (22 loc) • 747 B
JavaScript
import { Kuznyechik, BLOCK_SIZE } from "../index.js";
import { ecb_encrypt, ecb_decrypt } from "@li0ard/gost3413";
/**
* Encrypts data using Electronic Codebook (ECB) mode with Kuznyechik cipher.
*
* @param key Encryption key
* @param data Data to be encrypted
*/
export const encryptECB = (key, data) => {
const cipher = new Kuznyechik(key);
return ecb_encrypt(cipher.encryptBlock.bind(cipher), BLOCK_SIZE, data);
};
/**
* Decrypts data using Electronic Codebook (ECB) mode with Kuznyechik cipher.
*
* @param key Encryption key
* @param data Data to be decrypted
*/
export const decryptECB = (key, data) => {
const cipher = new Kuznyechik(key);
return ecb_decrypt(cipher.decryptBlock.bind(cipher), BLOCK_SIZE, data);
};