plinth/browser/crypto/subtle

Types

pub type CryptoKey
pub type DigestAlgorithm {
  SHA1
  SHA256
  SHA384
  SHA512
}

Constructors

  • SHA1
  • SHA256
  • SHA384
  • SHA512
pub type KeyUsage {
  Encrypt
  Decrypt
  Sign
  Verify
  DeriveKey
  DeriveBits
  WrapKey
  UnwrapKey
}

Constructors

  • Encrypt
  • Decrypt
  • Sign
  • Verify
  • DeriveKey
  • DeriveBits
  • WrapKey
  • UnwrapKey
pub type PublicKeyAlgorithm {
  EcKeyGenParams(name: String, named_curve: String)
}

Constructors

  • EcKeyGenParams(name: String, named_curve: String)
pub type SignAlgorithm {
  EcdsaParams(hash: DigestAlgorithm)
}

Constructors

  • EcdsaParams(hash: DigestAlgorithm)

Values

pub fn digest(
  algorithm: DigestAlgorithm,
  data: BitArray,
) -> Promise(Result(BitArray, String))
pub fn digest_algorithm_to_string(
  algorithm: DigestAlgorithm,
) -> String
pub fn export_jwk(
  key: CryptoKey,
) -> Promise(Result(Json, String))

export Jwk is separate because it returns JSON, other formats return array buffer

pub fn generate_key(
  algorithm: PublicKeyAlgorithm,
  extractable: Bool,
  key_usages: List(KeyUsage),
) -> Promise(Result(#(CryptoKey, CryptoKey), String))
pub fn sign(
  algorithm: SignAlgorithm,
  key: CryptoKey,
  data: BitArray,
) -> Promise(Result(BitArray, String))
Search Document