UNPKG

@li0ard/kuznyechik

Version:

Kuznyechik cipher implementation in pure TypeScript

22 lines (21 loc) 672 B
import { BLOCK_SIZE, Kuznyechik } from "../index.js"; import { ofb } from "@li0ard/gost3413"; /** * Encrypts data using the Output Feedback (OFB) mode with Kuznyechik cipher. * * @param key Encryption key * @param data Data to be encrypted * @param iv Initialization vector */ export const encryptOFB = (key, data, iv) => { const cipher = new Kuznyechik(key); return ofb(cipher.encryptBlock.bind(cipher), BLOCK_SIZE, data, iv); }; /** * Decrypts data using the Output Feedback (OFB) mode with Kuznyechik cipher. * * @param key Encryption key * @param data Data to be decrypted * @param iv Initialization vector */ export const decryptOFB = encryptOFB;