deno/lib/ncl
2025-09-26 19:38:24 +02:00
..
mod.ts scan for aruba aps in para/noia 2024-04-05 01:35:37 +02:00
pass.ts migrate std to jsr 2024-06-10 01:16:13 +01:00
readme.md lowercase readme 2025-09-26 19:38:24 +02:00

-/ncl

nano cryptography library

import { pair, rand, x25519 } from "-/ncl/mod.ts";

const [private_key, public_key] = pair();

const the_long_way = rand(32);
const the_long_way_pub = x25519(the_long_way);

const [private_key_2, public_key_2] = pair(the_long_way);
the_long_way === private_key_2;
the_long_way_pub === public_key_2;
import { bit, dice } from "-/ncl/mod.ts";

const single_random_bit = bit();

const initiative = dice(20) + 1;
const random_item = dice(array.length);
const ignore_first_10 = dice(array.length, 10);

this sacrifices speed for unbiased randomness, and trying to not waste entropy. that means it's not fit for every use case. for example, i wouldn't use it for a game server, but it's neat for generating passwords or keys.

spare entropy when rolling a dice gets recycled as best as possible. the first roll sets up the buffer for this, and might be a tiny bit slower than the following ones.

dependencies

  • nacl (some sort of libsodium wrapper compatible with tweetnacl)
  • -/base
    • @std/encoding
  • scule1
  • effwords1 (eff diceware, in particular the large word list)
    the format is { [dice_rolls]: "word" }, e.g. { 21552: "cuddle"}
    keys and order aren't important, values need to be unique

exports

name function
ncl/pass bitwarden-esque passphrase generator

  1. only for ncl/pass ↩︎