An ECMAScript module for NaCl / TweetNaCl high security cryptographic library.
Find a file
2026-05-09 18:02:50 +08:00
.github Update resources 2026-04-21 17:54:47 +08:00
_test Update test 2025-10-08 17:42:22 +08:00
.codeql.yml Update resources 2025-08-26 17:40:37 +08:00
.gitattributes Initial 2025-07-16 14:07:56 +08:00
.gitignore Update resources 2026-04-21 17:45:58 +08:00
.npm-codeberg.build.ts Update resources 2026-05-08 16:23:32 +08:00
.npm-github.build.ts Update resources 2026-05-08 16:23:32 +08:00
.npm-kaki87.build.ts Update resources 2026-05-08 16:23:32 +08:00
.npm-npm.build.ts Update resources 2026-05-08 16:23:32 +08:00
.yamllint.yml Initial 2025-07-16 14:07:56 +08:00
_random_bytes.ts Initial 2025-07-16 14:07:56 +08:00
CITATION.cff Initial 2025-07-16 14:07:56 +08:00
CONTRIBUTING.md Initial 2025-07-16 14:07:56 +08:00
deno.jsonc Update resources 2026-05-08 16:23:32 +08:00
jsr.jsonc Update resources 2026-04-22 17:57:10 +08:00
LICENSE.md Update resources 2026-02-01 16:18:27 +08:00
lowlevel.ts Update resources 2025-09-16 17:43:44 +08:00
mod.ts Fmt 2025-10-10 17:18:13 +08:00
README.md Update resources 2026-05-09 18:02:50 +08:00
SECURITY.md Update resources 2026-05-09 18:02:50 +08:00

NaCl (ES)

⚖️ MIT

🔗 GitHubJSRNPM

An ECMAScript module for NaCl / TweetNaCl high security cryptographic library.

This is a modified edition of the TweetNaCl JS which with ECMAScript and TypeScript.

🎯 Targets

Runtime \ Source GitHub Raw JSR NPM
Bun >= v1.1.0 ✔️ ✔️
Deno >= v2.1.0 ✔️ ✔️ ✔️
NodeJS >= v20.9.0 ✔️ ✔️

🛡️ Runtime Permissions

This does not request any runtime permission.

#️⃣ Sources

  • GitHub Raw
    https://raw.githubusercontent.com/hugoalh/nacl-es/{Tag}/mod.ts
    
  • JSR
    jsr:@hugoalh/nacl[@{Tag}]
    
  • NPM
    npm:@hugoalh/nacl[@{Tag}]
    

Note

  • It is recommended to include tag for immutability.
  • These are not part of the public APIs hence should not be used:
    • Benchmark/Test file (e.g.: example.bench.ts, example.test.ts).
    • Entrypoint name or path include any underscore prefix (e.g.: _example.ts, foo/_example.ts).
    • Identifier/Namespace/Symbol include any underscore prefix (e.g.: _example, Foo._example).

⤵️ Entrypoints

Name Path Description
. ./mod.ts Default. High level APIs.
./lowlevel ./lowlevel.ts Low level APIs.

🧩 APIs

  • function box(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
    
  • function boxBefore(publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array;
    
  • function boxKeyPair(): KeyPair;
    
  • function boxKeyPairFromSecretKey(secretKey: Uint8Array): KeyPair;
    
  • function boxOpen(msg: Uint8Array, nonce: Uint8Array, publicKey: Uint8Array, secretKey: Uint8Array): Uint8Array | null;
    
  • function hash(msg: Uint8Array): Uint8Array;
    
  • function scalarMult(n: Uint8Array, p: Uint8Array): Uint8Array;
    
  • function scalarMultBase(n: Uint8Array): Uint8Array;
    
  • function secretBox(msg: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array;
    
  • function secretBoxOpen(box: Uint8Array, nonce: Uint8Array, key: Uint8Array): Uint8Array | null;
    
  • function sign(msg: Uint8Array, secretKey: Uint8Array): Uint8Array;
    
  • function signDetached(msg: Uint8Array, secretKey: Uint8Array): Uint8Array;
    
  • function signDetachedVerify(msg: Uint8Array, sig: Uint8Array, publicKey: Uint8Array): boolean;
    
  • function signKeyPair(): KeyPair;
    
  • function signKeyPairFromSecretKey(secretKey: Uint8Array): KeyPair;
    
  • function signKeyPairFromSeed(seed: Uint8Array): KeyPair;
    
  • function signOpen(signedMsg: Uint8Array, publicKey: Uint8Array): Uint8Array | null;
    
  • function verify(x: Uint8Array, y: Uint8Array): boolean;
    
  • interface KeyPair {
      publicKey: Uint8Array;
      secretKey: Uint8Array;
    }
    

Note