Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

cryptokuznechik

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptokuznechik

An npm package that provides cryptography russian algorithm 'kuznechik' (GOST 34.12-2018)

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
2
Created
Source

CryptoKuznechik

This is a simple package that provides a russian cryptography algorithm "kuznechik" (GOST 34.12-2018)

How to install

To install this package enter command below to terminal: npm install cryptokuznechik

Usage

To use this package firstly you need to choose one of the encryption mods:

  • ECB
  • OFB
  • CFB
  • CTR
  • OFB

ECB

For ECB you need to import class ECB from package:

import {ECB} from 'cryptokuznechik';

Next create an instance of ECB:

let ecb:ECB = new ECB();

Now you can encrypt and decrypt messages:

const fs = require('fs');
let inputString: string = fs.readFileSync("input.txt", "utf8");
let encrypted: Buffer = ecb.Encrypt(Buffer.from(inputString));

let result: Buffer = ecb.Decrypt(encrypted);

CBC

For CBC you need to import class CBC from package:

import {CBC} from 'cryptokuznechik';

Next create an instance of CBC:

let cbc:CBC = new CBC();

Now encrypt and decrypt messages:

let buffer: Buffer = Buffer.from(inputString);
let cbc_enc: Buffer = cbc.Encrypt(buffer);
let result: Buffer = cbc.Decrypt(cbc_enc);

CFB

For CFB you need to import class CFB from package:

import {CFB} from 'cryptokuznechik';

Next create an instance of CFB:

let cfb:CFB = new CFB();

Now encrypt and decrypt messages:

let cfb_enc: Buffer = cfb.Encrypt(buffer);
let result: Buffer = cfb.Decrypt(cfb_enc);

CTR

For CTR you need to import class CTR from package:

import {CTR} from 'cryptokuznechik';

Next create an instance of CTR:

let ctr:CTR = new CTR();

Now encrypt and decrypt messages:

let ctr_enc: Buffer = ctr.Encrypt(buffer);
let result: Buffer = ctr.Decrypt(ctr_enc);

OFB

For OFB you need to import class OFB from package:

import {OFB} from 'cryptokuznechik';

Next create an instance of OFB:

let ofb:OFB = new OFB();

Now encrypt and decrypt messages:

let ofb_enc: Buffer = ofb.Encrypt(buffer);
let result: Buffer = ofb.Decrypt(ofb_enc);

Other

You also can create your own encryption mode with Kuznec:

import {Kuznec} from 'cryptokuznechik'

let kuz: Kuznec = new Kuznec();
let block: Buffer = Buffer.from('plainTextBlock12');
let encrypted_block: Buffer = kuz.Encryption(block);
let decrypted_block: Buffer = kuz.Decryption(encrypted_block);
console.log(decrypted_block.toString('utf-8')); //// plainTextBlock12

Authors

* lokt02
* KostylevVadim

Special thanks

* PotatoHD404

Keywords

grasshopper

FAQs

Package last updated on 15 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts