Package-level declarations

Types

Link copied to clipboard
sealed external interface AsymmetricKeyDetails
Link copied to clipboard
sealed external interface BasePrivateKeyEncodingOptions<T : KeyFormat>
Link copied to clipboard
typealias BinaryLike = Any
Link copied to clipboard
sealed external interface BinaryToTextEncoding
Link copied to clipboard
external class Certificate

SPKAC is a Certificate Signing Request mechanism originally implemented by Netscape and was specified formally as part of HTML5's keygen element.

Link copied to clipboard
sealed external interface CharacterEncoding
Link copied to clipboard
sealed external interface CheckPrimeOptions
Link copied to clipboard
open external class Cipher : Transform

Instances of the Cipher class are used to encrypt data. The class can be used in one of two ways:

Link copied to clipboard
sealed external interface CipherCCM : Cipher
Link copied to clipboard
sealed external interface CipherCCMOptions : TransformOptions
Link copied to clipboard
sealed external interface CipherCCMSetAADOptions
Link copied to clipboard
sealed external interface CipherCCMTypes
Link copied to clipboard
sealed external interface CipherGCM : Cipher
Link copied to clipboard
sealed external interface CipherGCMOptions : TransformOptions
Link copied to clipboard
sealed external interface CipherGCMSetAADOptions
Link copied to clipboard
sealed external interface CipherGCMTypes
Link copied to clipboard
sealed external interface CipherInfo
Link copied to clipboard
sealed external interface CipherInfoOptions
Link copied to clipboard
typealias CipherKey = Any
Link copied to clipboard
sealed external interface CipherMode
Link copied to clipboard
sealed external interface CipherOCB : Cipher
Link copied to clipboard
sealed external interface CipherOCBOptions : TransformOptions
Link copied to clipboard
sealed external interface CipherOCBSetAADOptions
Link copied to clipboard
sealed external interface CipherOCBTypes
Link copied to clipboard
open external class Decipher : Transform

Instances of the Decipher class are used to decrypt data. The class can be used in one of two ways:

Link copied to clipboard
sealed external interface DecipherCCM : Decipher
Link copied to clipboard
sealed external interface DecipherCCMSetAADOptions
Link copied to clipboard
sealed external interface DecipherGCM : Decipher
Link copied to clipboard
sealed external interface DecipherGCMSetAADOptions
Link copied to clipboard
sealed external interface DecipherOCB : Decipher
Link copied to clipboard
sealed external interface DecipherOCBSetAADOptions
Link copied to clipboard
external class DiffieHellman

The DiffieHellman class is a utility for creating Diffie-Hellman key exchanges.

Link copied to clipboard
sealed external class DiffieHellmanGroup
Link copied to clipboard
sealed external interface DiffieHellmanOptions
Link copied to clipboard
sealed external interface DSAEncoding
Link copied to clipboard
sealed external interface DSAKeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface DSAKeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
Link copied to clipboard
external class ECDH

The ECDH class is a utility for creating Elliptic Curve Diffie-Hellman (ECDH) key exchanges.

Link copied to clipboard
sealed external interface ECDHConvertKeyFormat
Link copied to clipboard
sealed external interface ECDHConvertKeyOutputEncoding
Link copied to clipboard
sealed external interface ECDHKeyFormat
Link copied to clipboard
sealed external interface ECKeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface ECKeyPairKeyObjectOptionsParamEncoding
Link copied to clipboard
Link copied to clipboard
sealed external interface ECKeyPairOptionsPrivateKeyEncodingType
Link copied to clipboard
sealed external interface ECKeyPairOptionsPublicKeyEncoding<PubF : KeyFormat>
Link copied to clipboard
sealed external interface ECKeyPairOptionsPublicKeyEncodingType
Link copied to clipboard
sealed external interface ED25519KeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface ED25519KeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
sealed external interface ED448KeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface ED448KeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
Link copied to clipboard
typealias Encoding = Any
Link copied to clipboard
sealed external interface GenerateKeyOptions
Link copied to clipboard
sealed external interface GenerateKeySyncOptions
Link copied to clipboard
sealed external interface GenerateKeySyncType
Link copied to clipboard
sealed external interface GenerateKeyType
Link copied to clipboard
sealed external interface GeneratePrimeOptions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
external class Hash : Transform

The Hash class is a utility for creating hash digests of data. It can be used in one of two ways:

Link copied to clipboard
sealed external interface HashOptions : TransformOptions
Link copied to clipboard
external class Hmac : Transform

The Hmac class is a utility for creating cryptographic HMAC digests. It can be used in one of two ways:

Link copied to clipboard
sealed external interface JsonWebKey
Link copied to clipboard
sealed external interface JsonWebKeyInput
Link copied to clipboard
sealed external interface JwkKeyExportOptions
Link copied to clipboard
sealed external interface KeyExportOptions<T : KeyFormat>
Link copied to clipboard
sealed external interface KeyExportOptionsType
Link copied to clipboard
sealed external interface KeyFormat
Link copied to clipboard
typealias KeyLike = Any
Link copied to clipboard
external class KeyObject

Node.js uses a KeyObject class to represent a symmetric or asymmetric key, and each kind of key exposes different functions. The {@link createSecretKey}, {@link createPublicKey} and {@link createPrivateKey} methods are used to create KeyObjectinstances. KeyObject objects are not to be created directly using the newkeyword.

Link copied to clipboard
sealed external interface KeyObjectType
Link copied to clipboard
sealed external interface KeyPairKeyObjectResult
Link copied to clipboard
sealed external interface KeyPairSyncResult<T1 : Any, T2 : Any>
Link copied to clipboard
sealed external interface KeyType
Link copied to clipboard
typealias LargeNumberLike = Any
Link copied to clipboard
sealed external interface LegacyCharacterEncoding
Link copied to clipboard
sealed external interface PrivateKeyInput
Link copied to clipboard
sealed external interface PrivateKeyInputType
Link copied to clipboard
sealed external interface PublicKeyInput
Link copied to clipboard
sealed external interface PublicKeyInputType
Link copied to clipboard
sealed external interface RandomUUIDOptions
Link copied to clipboard
sealed external interface RSAKeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface RSAKeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
sealed external interface RSAKeyPairOptionsPrivateKeyEncodingType
Link copied to clipboard
Link copied to clipboard
sealed external interface RSAKeyPairOptionsPublicKeyEncodingType
Link copied to clipboard
sealed external interface RsaPrivateKey
Link copied to clipboard
sealed external interface RSAPSSKeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface RSAPSSKeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
Link copied to clipboard
sealed external interface RsaPublicKey
Link copied to clipboard
sealed external interface ScryptOptions
Link copied to clipboard
sealed external interface SecureHeapUsage
Link copied to clipboard
external class Sign : Writable

The Sign class is a utility for generating signatures. It can be used in one of two ways:

Link copied to clipboard
sealed external interface SigningOptions
Link copied to clipboard
Link copied to clipboard
sealed external interface SignKeyObjectInput : SigningOptions
Link copied to clipboard
Link copied to clipboard
typealias UUID = String
Link copied to clipboard
external class Verify : Writable

The Verify class is a utility for verifying signatures. It can be used in one of two ways:

Link copied to clipboard
Link copied to clipboard
sealed external interface VerifyKeyObjectInput : SigningOptions
Link copied to clipboard
Link copied to clipboard
sealed external interface X25519KeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface X25519KeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
Link copied to clipboard
sealed external interface X448KeyPairKeyObjectOptions
Link copied to clipboard
sealed external interface X448KeyPairOptions<PubF : KeyFormat, PrivF : KeyFormat>
Link copied to clipboard
Link copied to clipboard
external class X509Certificate

Encapsulates an X509 certificate and provides read-only access to its information.

Link copied to clipboard
sealed external interface X509CheckOptions
Link copied to clipboard
sealed external interface X509CheckOptionsSubject

Properties

Link copied to clipboard
external val fips: Boolean
Link copied to clipboard
external val subtle: SubtleCrypto

A convenient alias for crypto.webcrypto.subtle.

Link copied to clipboard
external val webcrypto: Crypto

An implementation of the Web Crypto API standard.

Functions

Link copied to clipboard
external fun checkPrime(value: LargeNumberLike, callback: (JsError?, result: Boolean) -> Unit)

Checks the primality of the candidate.

external fun checkPrime(value: LargeNumberLike, options: CheckPrimeOptions, callback: (JsError?, result: Boolean) -> Unit)
Link copied to clipboard
external fun checkPrimeSync(candidate: LargeNumberLike, options: CheckPrimeOptions = definedExternally): Boolean

Checks the primality of the candidate.

Link copied to clipboard
external fun createCipheriv(algorithm: String, key: CipherKey, iv: BinaryLike?, options: TransformOptions = definedExternally): Cipher
external fun createCipheriv(algorithm: CipherGCMTypes, key: CipherKey, iv: BinaryLike, options: CipherGCMOptions = definedExternally): CipherGCM
external fun createCipheriv(algorithm: CipherOCBTypes, key: CipherKey, iv: BinaryLike, options: CipherOCBOptions): CipherOCB

external fun createCipheriv(algorithm: CipherCCMTypes, key: CipherKey, iv: BinaryLike, options: CipherCCMOptions): CipherCCM

Creates and returns a Cipher object, with the given algorithm, key and initialization vector (iv).

Link copied to clipboard
external fun createDecipheriv(algorithm: String, key: CipherKey, iv: BinaryLike?, options: TransformOptions = definedExternally): Decipher
external fun createDecipheriv(algorithm: CipherGCMTypes, key: CipherKey, iv: BinaryLike, options: CipherGCMOptions = definedExternally): DecipherGCM
external fun createDecipheriv(algorithm: CipherOCBTypes, key: CipherKey, iv: BinaryLike, options: CipherOCBOptions): DecipherOCB

external fun createDecipheriv(algorithm: CipherCCMTypes, key: CipherKey, iv: BinaryLike, options: CipherCCMOptions): DecipherCCM

Creates and returns a Decipher object that uses the given algorithm, key and initialization vector (iv).

Link copied to clipboard
external fun createDiffieHellman(prime: ArrayBuffer, generator: ArrayBuffer = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: ArrayBuffer, generator: ArrayBufferView = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: ArrayBuffer, generator: Double = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: ArrayBufferView, generator: ArrayBuffer = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: ArrayBufferView, generator: ArrayBufferView = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: ArrayBufferView, generator: Double = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: String, primeEncoding: BinaryToTextEncoding): DiffieHellman
external fun createDiffieHellman(prime: ArrayBuffer, generator: String, generatorEncoding: BinaryToTextEncoding): DiffieHellman
external fun createDiffieHellman(prime: ArrayBufferView, generator: String, generatorEncoding: BinaryToTextEncoding): DiffieHellman
external fun createDiffieHellman(prime: String, primeEncoding: BinaryToTextEncoding, generator: ArrayBuffer = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: String, primeEncoding: BinaryToTextEncoding, generator: ArrayBufferView = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: String, primeEncoding: BinaryToTextEncoding, generator: Double = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: String, primeEncoding: BinaryToTextEncoding, generator: String, generatorEncoding: BinaryToTextEncoding): DiffieHellman

external fun createDiffieHellman(primeLength: Number, generator: Number = definedExternally): DiffieHellman

Creates a DiffieHellman key exchange object using the supplied prime and an optional specific generator.

Link copied to clipboard

An alias for {@link getDiffieHellman}

Link copied to clipboard
external fun createECDH(curveName: String): ECDH

Creates an Elliptic Curve Diffie-Hellman (ECDH) key exchange object using a predefined curve specified by the curveName string. Use {@link getCurves} to obtain a list of available curve names. On recent OpenSSL releases, openssl ecparam -list_curves will also display the name and description of each available elliptic curve.

Link copied to clipboard
external fun createHash(algorithm: String, options: HashOptions = definedExternally): Hash

Creates and returns a Hash object that can be used to generate hash digests using the given algorithm. Optional options argument controls stream behavior. For XOF hash functions such as 'shake256', the outputLength option can be used to specify the desired output length in bytes.

Link copied to clipboard
external fun createHmac(algorithm: String, key: BinaryLike, options: TransformOptions = definedExternally): Hmac
external fun createHmac(algorithm: String, key: KeyObject, options: TransformOptions = definedExternally): Hmac

Creates and returns an Hmac object that uses the given algorithm and key. Optional options argument controls stream behavior.

Link copied to clipboard
external fun createPrivateKey(key: String): KeyObject
external fun createPrivateKey(key: Buffer): KeyObject

Creates and returns a new key object containing a private key. If key is a string or Buffer, format is assumed to be 'pem'; otherwise, key must be an object with the properties described above.

Link copied to clipboard
external fun createPublicKey(key: String): KeyObject
external fun createPublicKey(key: Buffer): KeyObject
external fun createPublicKey(key: KeyObject): KeyObject

Creates and returns a new key object containing a public key. If key is a string or Buffer, format is assumed to be 'pem'; if key is a KeyObject with type 'private', the public key is derived from the given private key; otherwise, key must be an object with the properties described above.

Link copied to clipboard

Creates and returns a new key object containing a secret key for symmetric encryption or Hmac.

external fun createSecretKey(key: String, encoding: BufferEncoding): KeyObject
Link copied to clipboard
external fun createSign(algorithm: String, options: WritableOptions = definedExternally): Sign

Creates and returns a Sign object that uses the given algorithm. Use {@link getHashes} to obtain the names of the available digest algorithms. Optional options argument controls the stream.Writable behavior.

Link copied to clipboard
external fun createVerify(algorithm: String, options: WritableOptions = definedExternally): Verify

Creates and returns a Verify object that uses the given algorithm. Use {@link getHashes} to obtain an array of names of the available signing algorithms. Optional options argument controls the stream.Writable behavior.

Link copied to clipboard
external fun diffieHellman(options: DiffieHellmanOptions): Buffer

Computes the Diffie-Hellman secret based on a privateKey and a publicKey. Both keys must have the same asymmetricKeyType, which must be one of 'dh' (for Diffie-Hellman), 'ec' (for ECDH), 'x448', or 'x25519' (for ECDH-ES).

Link copied to clipboard
external fun generateKey(type: GenerateKeyType, options: GenerateKeyOptions, callback: (JsError?, key: KeyObject) -> Unit)

Asynchronously generates a new random secret key of the given length. The type will determine which validations will be performed on the length.

Link copied to clipboard
external fun generateKeyPair(type: KeyType.dsa, options: DSAKeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.dsa, options: DSAKeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.dsa, options: DSAKeyPairKeyObjectOptions, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.dsa, options: DSAKeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.dsa, options: DSAKeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.ec, options: ECKeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.ec, options: ECKeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.ec, options: ECKeyPairKeyObjectOptions, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.ec, options: ECKeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.ec, options: ECKeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.ed25519, options: ED25519KeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.ed25519, options: ED25519KeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.ed25519, options: ED25519KeyPairKeyObjectOptions?, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.ed25519, options: ED25519KeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.ed25519, options: ED25519KeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.ed448, options: ED448KeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.ed448, options: ED448KeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.ed448, options: ED448KeyPairKeyObjectOptions?, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.ed448, options: ED448KeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.ed448, options: ED448KeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.rsa, options: RSAKeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.rsa, options: RSAKeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.rsa, options: RSAKeyPairKeyObjectOptions, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.rsa, options: RSAKeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.rsaPss, options: RSAPSSKeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.rsaPss, options: RSAPSSKeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.rsaPss, options: RSAPSSKeyPairKeyObjectOptions, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.rsaPss, options: RSAPSSKeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.rsaPss, options: RSAPSSKeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.x25519, options: X25519KeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.x25519, options: X25519KeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.x25519, options: X25519KeyPairKeyObjectOptions?, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.x25519, options: X25519KeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.x25519, options: X25519KeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.x448, options: X448KeyPairDerDerOptions, callback: (JsError?, publicKey: Buffer, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.x448, options: X448KeyPairDerPemOptions, callback: (JsError?, publicKey: Buffer, privateKey: String) -> Unit)
external fun generateKeyPair(type: KeyType.x448, options: X448KeyPairKeyObjectOptions?, callback: (JsError?, publicKey: KeyObject, privateKey: KeyObject) -> Unit)
external fun generateKeyPair(type: KeyType.x448, options: X448KeyPairPemDerOptions, callback: (JsError?, publicKey: String, privateKey: Buffer) -> Unit)
external fun generateKeyPair(type: KeyType.x448, options: X448KeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)

external fun generateKeyPair(type: KeyType.rsa, options: RSAKeyPairPemPemOptions, callback: (JsError?, publicKey: String, privateKey: String) -> Unit)

Generates a new asymmetric key pair of the given type. RSA, RSA-PSS, DSA, EC, Ed25519, Ed448, X25519, X448, and DH are currently supported.

Link copied to clipboard
external fun generateKeyPairSync(type: KeyType.x448, options: X448KeyPairKeyObjectOptions = definedExternally): KeyPairKeyObjectResult

Generates a new asymmetric key pair of the given type. RSA, RSA-PSS, DSA, EC, Ed25519, Ed448, X25519, X448, and DH are currently supported.

Link copied to clipboard

Synchronously generates a new random secret key of the given length. The type will determine which validations will be performed on the length.

Link copied to clipboard
external fun generatePrime(size: Number, callback: (JsError?, prime: ArrayBuffer) -> Unit)

Generates a pseudorandom prime of size bits.

external fun generatePrime(size: Number, options: GeneratePrimeOptions, callback: (JsError?, prime: Any) -> Unit)
external fun generatePrime(size: Number, options: GeneratePrimeOptionsArrayBuffer, callback: (JsError?, prime: ArrayBuffer) -> Unit)
external fun generatePrime(size: Number, options: GeneratePrimeOptionsBigInt, callback: (JsError?, prime: BigInt) -> Unit)
Link copied to clipboard
external fun generatePrimeSync(size: Number): ArrayBuffer

Generates a pseudorandom prime of size bits.

external fun generatePrimeSync(size: Number, options: GeneratePrimeOptions): Any
Link copied to clipboard
external fun getCipherInfo(nameOrNid: Double, options: CipherInfoOptions = definedExternally): CipherInfo?
external fun getCipherInfo(nameOrNid: String, options: CipherInfoOptions = definedExternally): CipherInfo?

Returns information about a given cipher.

Link copied to clipboard
Link copied to clipboard
external fun getCurves(): ReadonlyArray<String>
Link copied to clipboard
external fun getDiffieHellman(groupName: String): DiffieHellmanGroup

Creates a predefined DiffieHellmanGroup key exchange object. The supported groups are listed in the documentation for DiffieHellmanGroup.

Link copied to clipboard
external fun getFips(): Any
Link copied to clipboard
external fun getHashes(): ReadonlyArray<String>
Link copied to clipboard
external fun <T : BufferSource> getRandomValues(typedArray: T): T

A convenient alias for {@link webcrypto.getRandomValues}. This implementation is not compliant with the Web Crypto spec, to write web-compatible code use {@link webcrypto.getRandomValues} instead.

Link copied to clipboard
external fun hash(algorithm: String, data: BinaryLike): Any
external fun hash(algorithm: String, data: BinaryLike, outputEncoding: String): Buffer

external fun hash(algorithm: String, data: BinaryLike, outputEncoding: BinaryToTextEncoding = definedExternally): String

A utility for creating one-shot hash digests of data. It can be faster than the object-based crypto.createHash() when hashing a smaller amount of data (<= 5MB) that's readily available. If the data can be big or if it is streamed, it's still recommended to use crypto.createHash() instead. The algorithm is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are 'sha256', 'sha512', etc. On recent releases of OpenSSL, openssl list -digest-algorithms will display the available digest algorithms.

Link copied to clipboard
external fun hkdf(digest: String, irm: BinaryLike, salt: BinaryLike, info: BinaryLike, keylen: Number, callback: (JsError?, derivedKey: ArrayBuffer) -> Unit)
external fun hkdf(digest: String, irm: KeyObject, salt: BinaryLike, info: BinaryLike, keylen: Number, callback: (JsError?, derivedKey: ArrayBuffer) -> Unit)

HKDF is a simple key derivation function defined in RFC 5869\. The given ikm, salt and info are used with the digest to derive a key of keylen bytes.

Link copied to clipboard
external fun hkdfSync(digest: String, ikm: BinaryLike, salt: BinaryLike, info: BinaryLike, keylen: Number): ArrayBuffer
external fun hkdfSync(digest: String, ikm: KeyObject, salt: BinaryLike, info: BinaryLike, keylen: Number): ArrayBuffer

Provides a synchronous HKDF key derivation function as defined in RFC 5869\. The given ikm, salt and info are used with the digest to derive a key of keylen bytes.

Link copied to clipboard
external fun pbkdf2(password: BinaryLike, salt: BinaryLike, iterations: Number, keylen: Number, digest: String, callback: (JsError?, derivedKey: Buffer) -> Unit)

Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by digest is applied to derive a key of the requested byte length (keylen) from the password, salt and iterations.

Link copied to clipboard
external fun pbkdf2Sync(password: BinaryLike, salt: BinaryLike, iterations: Number, keylen: Number, digest: String): Buffer

Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by digest is applied to derive a key of the requested byte length (keylen) from the password, salt and iterations.

Link copied to clipboard
external fun privateDecrypt(privateKey: KeyLike, buffer: ArrayBufferView): Buffer
external fun privateDecrypt(privateKey: RsaPrivateKey, buffer: ArrayBufferView): Buffer

Decrypts buffer with privateKey. buffer was previously encrypted using the corresponding public key, for example using {@link publicEncrypt}.

Link copied to clipboard
external fun privateEncrypt(privateKey: KeyLike, buffer: ArrayBufferView): Buffer
external fun privateEncrypt(privateKey: RsaPrivateKey, buffer: ArrayBufferView): Buffer

Encrypts buffer with privateKey. The returned data can be decrypted using the corresponding public key, for example using {@link publicDecrypt}.

Link copied to clipboard
external fun pseudoRandomBytes(size: Number): Buffer
external fun pseudoRandomBytes(size: Number, callback: (JsError?, buf: Buffer) -> Unit)
Link copied to clipboard
external fun publicDecrypt(key: KeyLike, buffer: ArrayBufferView): Buffer
external fun publicDecrypt(key: RsaPrivateKey, buffer: ArrayBufferView): Buffer
external fun publicDecrypt(key: RsaPublicKey, buffer: ArrayBufferView): Buffer

Decrypts buffer with key.buffer was previously encrypted using the corresponding private key, for example using {@link privateEncrypt}.

Link copied to clipboard
external fun publicEncrypt(key: KeyLike, buffer: ArrayBufferView): Buffer
external fun publicEncrypt(key: RsaPrivateKey, buffer: ArrayBufferView): Buffer
external fun publicEncrypt(key: RsaPublicKey, buffer: ArrayBufferView): Buffer

Encrypts the content of buffer with key and returns a new Buffer with encrypted content. The returned data can be decrypted using the corresponding private key, for example using {@link privateDecrypt}.

Link copied to clipboard
external fun randomBytes(size: Number): Buffer

Generates cryptographically strong pseudorandom data. The size argument is a number indicating the number of bytes to generate.

external fun randomBytes(size: Number, callback: (JsError?, buf: Buffer) -> Unit)
Link copied to clipboard
external fun <T : ArrayBufferView> randomFill(buffer: T, callback: (JsError?, buf: T) -> Unit)

This function is similar to {@link randomBytes} but requires the first argument to be a Buffer that will be filled. It also requires that a callback is passed in.

external fun <T : ArrayBufferView> randomFill(buffer: T, offset: Number, callback: (JsError?, buf: T) -> Unit)
external fun <T : ArrayBufferView> randomFill(buffer: T, offset: Number, size: Number, callback: (JsError?, buf: T) -> Unit)
Link copied to clipboard
external fun <T : ArrayBufferView> randomFillSync(buffer: T, offset: Number = definedExternally, size: Number = definedExternally): T

Synchronous version of {@link randomFill}.

Link copied to clipboard
external fun randomInt(max: Number): Double

Return a random integer n such that min <= n < max. This implementation avoids modulo bias.

external fun randomInt(max: Number, callback: (JsError?, value: Double) -> Unit)
external fun randomInt(min: Number, max: Number): Double
external fun randomInt(min: Number, max: Number, callback: (JsError?, value: Double) -> Unit)
Link copied to clipboard
external fun randomUUID(options: RandomUUIDOptions = definedExternally): UUID

Generates a random RFC 4122 version 4 UUID. The UUID is generated using a cryptographic pseudorandom number generator.

Link copied to clipboard
external fun scrypt(password: BinaryLike, salt: BinaryLike, keylen: Number, callback: (JsError?, derivedKey: Buffer) -> Unit)

Provides an asynchronous scrypt implementation. Scrypt is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.

external fun scrypt(password: BinaryLike, salt: BinaryLike, keylen: Number, options: ScryptOptions, callback: (JsError?, derivedKey: Buffer) -> Unit)
Link copied to clipboard
external fun scryptSync(password: BinaryLike, salt: BinaryLike, keylen: Number, options: ScryptOptions = definedExternally): Buffer

Provides a synchronous scrypt implementation. Scrypt is a password-based key derivation function that is designed to be expensive computationally and memory-wise in order to make brute-force attacks unrewarding.

Link copied to clipboard
Link copied to clipboard
external fun setEngine(engine: String, flags: Number = definedExternally)

Load and set the engine for some or all OpenSSL functions (selected by flags).

Link copied to clipboard
external fun setFips(bool: Boolean)

Enables the FIPS compliant crypto provider in a FIPS-enabled Node.js build. Throws an error if FIPS mode is not available.

Link copied to clipboard
external fun sign(algorithm: String?, data: ArrayBufferView, key: KeyLike): Buffer
external fun sign(algorithm: String?, data: ArrayBufferView, key: SignJsonWebKeyInput): Buffer
external fun sign(algorithm: String?, data: ArrayBufferView, key: SignKeyObjectInput): Buffer
external fun sign(algorithm: String?, data: ArrayBufferView, key: SignPrivateKeyInput): Buffer

Calculates and returns the signature for data using the given private key and algorithm. If algorithm is null or undefined, then the algorithm is dependent upon the key type (especially Ed25519 and Ed448).

external fun sign(algorithm: String?, data: ArrayBufferView, key: KeyLike, callback: (JsError?, data: Buffer) -> Unit)
external fun sign(algorithm: String?, data: ArrayBufferView, key: SignJsonWebKeyInput, callback: (JsError?, data: Buffer) -> Unit)
external fun sign(algorithm: String?, data: ArrayBufferView, key: SignKeyObjectInput, callback: (JsError?, data: Buffer) -> Unit)
external fun sign(algorithm: String?, data: ArrayBufferView, key: SignPrivateKeyInput, callback: (JsError?, data: Buffer) -> Unit)
Link copied to clipboard

This function compares the underlying bytes that represent the given ArrayBuffer, TypedArray, or DataView instances using a constant-time algorithm.

Link copied to clipboard
external fun verify(algorithm: String?, data: ArrayBufferView, key: KeyLike, signature: ArrayBufferView): Boolean
external fun verify(algorithm: String?, data: ArrayBufferView, key: VerifyJsonWebKeyInput, signature: ArrayBufferView): Boolean
external fun verify(algorithm: String?, data: ArrayBufferView, key: VerifyKeyObjectInput, signature: ArrayBufferView): Boolean
external fun verify(algorithm: String?, data: ArrayBufferView, key: VerifyPublicKeyInput, signature: ArrayBufferView): Boolean

Verifies the given signature for data using the given key and algorithm. If algorithm is null or undefined, then the algorithm is dependent upon the key type (especially Ed25519 and Ed448).

external fun verify(algorithm: String?, data: ArrayBufferView, key: KeyLike, signature: ArrayBufferView, callback: (JsError?, result: Boolean) -> Unit)
external fun verify(algorithm: String?, data: ArrayBufferView, key: VerifyJsonWebKeyInput, signature: ArrayBufferView, callback: (JsError?, result: Boolean) -> Unit)
external fun verify(algorithm: String?, data: ArrayBufferView, key: VerifyKeyObjectInput, signature: ArrayBufferView, callback: (JsError?, result: Boolean) -> Unit)
external fun verify(algorithm: String?, data: ArrayBufferView, key: VerifyPublicKeyInput, signature: ArrayBufferView, callback: (JsError?, result: Boolean) -> Unit)