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<Transform>
Link copied to clipboard
sealed external interface CipherCCMSetAADOptions
Link copied to clipboard
sealed external interface CipherCCMTypes
Link copied to clipboard
sealed external interface CipherChaCha20Poly1305 : Cipher
Link copied to clipboard
Link copied to clipboard
sealed external interface CipherChaCha20Poly1305SetAADOptions
Link copied to clipboard
Link copied to clipboard
sealed external interface CipherGCM : Cipher
Link copied to clipboard
sealed external interface CipherGCMOptions : TransformOptions<Transform>
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<Transform>
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 DecipherChaCha20Poly1305 : Decipher
Link copied to clipboard
sealed external interface DecipherChaCha20Poly1305SetAADOptions
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
sealed external interface GetFipsResult
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<Transform>
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: <Error class: unknown class>

A convenient alias for crypto.webcrypto.subtle.

Link copied to clipboard
external val webcrypto: <Error class: unknown class>

An implementation of the Web Crypto API standard.

Functions

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

Checks the primality of the candidate.

external fun checkPrime(value: LargeNumberLike, options: CheckPrimeOptions, callback: (<Error class: unknown class>?, 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: CipherChaCha20Poly1305Types,     key: CipherKey,     iv: BinaryLike,     options: CipherChaCha20Poly1305Options = definedExternally): CipherChaCha20Poly1305
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: CipherChaCha20Poly1305Types,     key: CipherKey,     iv: BinaryLike,     options: CipherChaCha20Poly1305Options = definedExternally): DecipherChaCha20Poly1305
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: <Error class: unknown class>): DiffieHellman
external fun createDiffieHellman(prime: <Error class: unknown class><out <Error class: unknown class>>): DiffieHellman
external fun createDiffieHellman(prime: <Error class: unknown class>, generator: <Error class: unknown class> = definedExternally): DiffieHellman
external fun createDiffieHellman(    prime: <Error class: unknown class>,     generator: <Error class: unknown class><out <Error class: unknown class>> = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: <Error class: unknown class>, generator: Double = definedExternally): DiffieHellman
external fun createDiffieHellman(    prime: <Error class: unknown class><out <Error class: unknown class>>,     generator: <Error class: unknown class> = definedExternally): DiffieHellman
external fun createDiffieHellman(    prime: <Error class: unknown class><out <Error class: unknown class>>,     generator: <Error class: unknown class><out <Error class: unknown class>> = definedExternally): DiffieHellman
external fun createDiffieHellman(    prime: <Error class: unknown class><out <Error class: unknown class>>,     generator: Double = definedExternally): DiffieHellman
external fun createDiffieHellman(prime: String, primeEncoding: BinaryToTextEncoding): DiffieHellman
external fun createDiffieHellman(prime: <Error class: unknown class>, generator: String, generatorEncoding: BinaryToTextEncoding): DiffieHellman
external fun createDiffieHellman(    prime: <Error class: unknown class><out <Error class: unknown class>>,     generator: String,     generatorEncoding: BinaryToTextEncoding): DiffieHellman
external fun createDiffieHellman(    prime: String,     primeEncoding: BinaryToTextEncoding,     generator: <Error class: unknown class> = definedExternally): DiffieHellman
external fun createDiffieHellman(    prime: String,     primeEncoding: BinaryToTextEncoding,     generator: <Error class: unknown class><out <Error class: unknown class>> = 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
external fun createSecretKey(key: <Error class: unknown class><out <Error class: unknown class>>): KeyObject

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

external fun generateKeyPair(    type: KeyType.rsa,     options: RSAKeyPairPemPemOptions,     callback: (<Error class: unknown class>?, 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: (<Error class: unknown class>?, <Error class: unknown class>) -> Unit)

Generates a pseudorandom prime of size bits.

external fun generatePrime(size: Number, options: GeneratePrimeOptions, callback: (<Error class: unknown class>?, prime: Any) -> Unit)
external fun generatePrime(    size: Number,     options: GeneratePrimeOptionsArrayBuffer,     callback: (<Error class: unknown class>?, <Error class: unknown class>) -> Unit)
external fun generatePrime(    size: Number,     options: GeneratePrimeOptionsBigInt,     callback: (<Error class: unknown class>?, <Error class: unknown class>) -> Unit)
Link copied to clipboard
external fun generatePrimeSync(size: Number): <Error class: unknown class>

Generates a pseudorandom prime of size bits.

external fun generatePrimeSync(size: Number, options: GeneratePrimeOptions): Any
external fun generatePrimeSync(size: Number, options: GeneratePrimeOptionsArrayBuffer): <Error class: unknown class>
external fun generatePrimeSync(size: Number, options: GeneratePrimeOptionsBigInt): <Error class: unknown class>
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
external fun getCiphers(): <Error class: unknown class><String>
Link copied to clipboard
external fun getCurves(): <Error class: unknown class><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(): GetFipsResult
Link copied to clipboard
external fun getHashes(): <Error class: unknown class><String>
Link copied to clipboard
external fun <T> 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: (<Error class: unknown class>?, <Error class: unknown class>) -> Unit)
external fun hkdf(    digest: String,     irm: KeyObject,     salt: BinaryLike,     info: BinaryLike,     keylen: Number,     callback: (<Error class: unknown class>?, <Error class: unknown class>) -> 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): <Error class: unknown class>
external fun hkdfSync(digest: String, ikm: KeyObject, salt: BinaryLike, info: BinaryLike, keylen: Number): <Error class: unknown class>

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: (<Error class: unknown class>?, 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: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun privateDecrypt(privateKey: KeyLike, buffer: String): Buffer<*>
external fun privateDecrypt(privateKey: RsaPrivateKey, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun privateDecrypt(privateKey: RsaPrivateKey, buffer: String): 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: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun privateEncrypt(privateKey: KeyLike, buffer: String): Buffer<*>
external fun privateEncrypt(privateKey: RsaPrivateKey, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun privateEncrypt(privateKey: RsaPrivateKey, buffer: String): 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: (<Error class: unknown class>?, buf: Buffer<*>) -> Unit)
Link copied to clipboard
external fun publicDecrypt(key: KeyLike, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun publicDecrypt(key: KeyLike, buffer: String): Buffer<*>
external fun publicDecrypt(key: RsaPrivateKey, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun publicDecrypt(key: RsaPrivateKey, buffer: String): Buffer<*>
external fun publicDecrypt(key: RsaPublicKey, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun publicDecrypt(key: RsaPublicKey, buffer: String): 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: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun publicEncrypt(key: KeyLike, buffer: String): Buffer<*>
external fun publicEncrypt(key: RsaPrivateKey, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun publicEncrypt(key: RsaPrivateKey, buffer: String): Buffer<*>
external fun publicEncrypt(key: RsaPublicKey, buffer: <Error class: unknown class><out <Error class: unknown class>>): Buffer<*>
external fun publicEncrypt(key: RsaPublicKey, buffer: String): 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: (<Error class: unknown class>?, buf: Buffer<*>) -> Unit)
Link copied to clipboard
external fun <T> randomFill(buffer: T, callback: (<Error class: unknown class>?, 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> randomFill(buffer: T, offset: Number, callback: (<Error class: unknown class>?, buf: T) -> Unit)
external fun <T> randomFill(buffer: T, offset: Number, size: Number, callback: (<Error class: unknown class>?, buf: T) -> Unit)
Link copied to clipboard
external fun <T> 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: (<Error class: unknown class>?, value: Double) -> Unit)
external fun randomInt(min: Number, max: Number): Double
external fun randomInt(min: Number, max: Number, callback: (<Error class: unknown class>?, 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: (<Error class: unknown class>?, 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: (<Error class: unknown class>?, 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: <Error class: unknown class><out <Error class: unknown class>>, key: KeyLike): Buffer<*>
external fun sign(algorithm: String?, data: <Error class: unknown class><out <Error class: unknown class>>, key: SignJsonWebKeyInput): Buffer<*>
external fun sign(algorithm: String?, data: <Error class: unknown class><out <Error class: unknown class>>, key: SignKeyObjectInput): Buffer<*>
external fun sign(algorithm: String?, data: <Error class: unknown class><out <Error class: unknown class>>, 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: <Error class: unknown class><out <Error class: unknown class>>,     key: KeyLike,     callback: (<Error class: unknown class>?, data: Buffer<*>) -> Unit)
external fun sign(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: SignJsonWebKeyInput,     callback: (<Error class: unknown class>?, data: Buffer<*>) -> Unit)
external fun sign(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: SignKeyObjectInput,     callback: (<Error class: unknown class>?, data: Buffer<*>) -> Unit)
external fun sign(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: SignPrivateKeyInput,     callback: (<Error class: unknown class>?, data: Buffer<*>) -> Unit)
Link copied to clipboard
external fun timingSafeEqual(    a: <Error class: unknown class><out <Error class: unknown class>>,     b: <Error class: unknown class><out <Error class: unknown class>>): Boolean

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: <Error class: unknown class><out <Error class: unknown class>>,     key: KeyLike,     signature: <Error class: unknown class><out <Error class: unknown class>>): Boolean
external fun verify(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: VerifyJsonWebKeyInput,     signature: <Error class: unknown class><out <Error class: unknown class>>): Boolean
external fun verify(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: VerifyKeyObjectInput,     signature: <Error class: unknown class><out <Error class: unknown class>>): Boolean
external fun verify(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: VerifyPublicKeyInput,     signature: <Error class: unknown class><out <Error class: unknown class>>): 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: <Error class: unknown class><out <Error class: unknown class>>,     key: KeyLike,     signature: <Error class: unknown class><out <Error class: unknown class>>,     callback: (<Error class: unknown class>?, result: Boolean) -> Unit)
external fun verify(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: VerifyJsonWebKeyInput,     signature: <Error class: unknown class><out <Error class: unknown class>>,     callback: (<Error class: unknown class>?, result: Boolean) -> Unit)
external fun verify(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: VerifyKeyObjectInput,     signature: <Error class: unknown class><out <Error class: unknown class>>,     callback: (<Error class: unknown class>?, result: Boolean) -> Unit)
external fun verify(    algorithm: String?,     data: <Error class: unknown class><out <Error class: unknown class>>,     key: VerifyPublicKeyInput,     signature: <Error class: unknown class><out <Error class: unknown class>>,     callback: (<Error class: unknown class>?, result: Boolean) -> Unit)