Skip to content

li0ard/kupyna

Repository files navigation

@li0ard/kupyna
Kupyna (DSTU 7564:2014) hash function in pure TypeScript
docs




Installation

# from NPM
npm i @li0ard/kupyna

# from JSR
bunx jsr i @li0ard/kupyna

Supported modes

  • Kupyna 48 bit
  • Kupyna 256 bit
  • Kupyna 304 bit
  • Kupyna 384 bit
  • Kupyna 512 bit
  • Kupyna KMAC 256 bit
  • Kupyna KMAC 384 bit
  • Kupyna KMAC 512 bit

Features

  • Provides simple and modern API
  • Most of the APIs are strictly typed
  • Fully complies with DSTU 7564:2014 standard
  • Supports Bun, Node.js, Deno, Browsers

Examples

Compute hash

import { Kupyna256 } from "@li0ard/kupyna"

let hash = new Kupyna256()
hash.update(new TextEncoder().encode("hello world"))
console.log(hash.digest())

// OR

import { kupyna256 } from "@li0ard/kupyna"

console.log(kupyna256(new TextEncoder().encode("hello world")))

Compute KMAC

import { KupynaKMAC256 } from "@li0ard/kupyna"

const msg = Buffer.from("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e", "hex")
const key = Buffer.from("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100", "hex")
let kmac = new KupynaKMAC256(key)
kmac.update(msg)
console.log(kmac.digest())