deno/ext/crypto
Nathan Whitaker 9379a74e08
Some checks are pending
ci / publish canary (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build libs (push) Blocked by required conditions
chore: update to edition 2024 (#29923)
2025-07-02 17:59:39 -07:00
..
00_crypto.js fix(ext/node): match WebCrypto tag too small error msg with Node (#29654) 2025-06-08 21:07:31 +05:30
Cargo.toml 2.4.0 (#29959) 2025-07-01 16:21:05 -04:00
decrypt.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
ed25519.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
encrypt.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
export_key.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
generate_key.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
import_key.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
key.rs chore: use aws_lc_rs (#28244) 2025-06-19 01:07:00 -07:00
lib.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
README.md refactor: allow lazy main module (#28929) 2025-04-30 19:59:20 +00:00
shared.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
x448.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00
x25519.rs chore: update to edition 2024 (#29923) 2025-07-02 17:59:39 -07:00

deno_crypto

This crate implements the Web Cryptography API.

Spec: https://www.w3.org/TR/WebCryptoAPI/

Usage Example

From javascript, include the extension's source, and assign CryptoKey, crypto, Crypto, and SubtleCrypto to the global scope:

import * as crypto from "ext:deno_crypto/00_crypto.js";

Object.defineProperty(globalThis, "CryptoKey", {
  value: crypto.CryptoKey,
  enumerable: false,
  configurable: true,
  writable: true,
});

Object.defineProperty(globalThis, "crypto", {
  value: crypto.crypto,
  enumerable: false,
  configurable: true,
  writable: false,
});

Object.defineProperty(globalThis, "Crypto", {
  value: crypto.Crypto,
  enumerable: false,
  configurable: true,
  writable: true,
});

Object.defineProperty(globalThis, "SubtleCrypto", {
  value: crypto.SubtleCrypto,
  enumerable: false,
  configurable: true,
  writable: true,
});

Then from rust, provide: deno_crypto::deno_crypto::init(Option<u64>) in the extensions field of your RuntimeOptions

Where the Option<u64> represents an optional seed for initialization.

Dependencies

  • deno_webidl: Provided by the deno_webidl crate
  • deno_web: Provided by the deno_web crate

Provided ops

Following ops are provided, which can be accessed through Deno.ops:

  • op_crypto_get_random_values
  • op_crypto_generate_key
  • op_crypto_sign_key
  • op_crypto_verify_key
  • op_crypto_derive_bits
  • op_crypto_import_key
  • op_crypto_export_key
  • op_crypto_encrypt
  • op_crypto_decrypt
  • op_crypto_subtle_digest
  • op_crypto_random_uuid
  • op_crypto_wrap_key
  • op_crypto_unwrap_key
  • op_crypto_base64url_decode
  • op_crypto_base64url_encode
  • x25519::op_crypto_generate_x25519_keypair
  • x25519::op_crypto_derive_bits_x25519
  • x25519::op_crypto_import_spki_x25519
  • x25519::op_crypto_import_pkcs8_x25519
  • ed25519::op_crypto_generate_ed25519_keypair
  • ed25519::op_crypto_import_spki_ed25519
  • ed25519::op_crypto_import_pkcs8_ed25519
  • ed25519::op_crypto_sign_ed25519
  • ed25519::op_crypto_verify_ed25519
  • ed25519::op_crypto_export_spki_ed25519
  • ed25519::op_crypto_export_pkcs8_ed25519
  • ed25519::op_crypto_jwk_x_ed25519
  • x25519::op_crypto_export_spki_x25519
  • x25519::op_crypto_export_pkcs8_x25519