Crypto
Provides a comprehensive interface for cryptographic operations. This class serves as a central point for accessing various cryptographic functionalities including algorithm retrieval, key generation, and cipher operations.
Constructors
new Crypto()
new Crypto(): Crypto
Returns
Methods
getAsymmetricAlgorithmByName()
getAsymmetricAlgorithmByName(name:
string): AsymmetricAlgorithm
Get an asymmetric algorithm by name.
This function retrieves an asymmetric algorithm by its name.
Parameters
name
string
The name of the asymmetric algorithm.
Throws
- If the algorithm name is invalid.
Returns
AsymmetricAlgorithm The requested asymmetric algorithm.
getDigestAlgorithmByName()
getDigestAlgorithmByName(name:
string): DigestAlgorithm
Get a digest algorithm by name.
This function retrieves a digest algorithm based on its name. If the algorithm with the given name is supported, it returns the requested algorithm.
Parameters
name
string
The name of the algorithm.
Throws
- If the algorithm name is invalid.
Returns
DigestAlgorithm The requested digest algorithm.
getEccCurveByName()
getEccCurveByName(name:
string): EccCurve
Get an elliptic-curve cryptography (ECC) curve by name.
This function retrieves an elliptic-curve cryptography curve by its name.
Parameters
name
string
The name of the ECC curve.
Throws
- If the curve name is invalid.
Returns
EccCurve The requested ECC curve.
getMajorVersion()
staticgetMajorVersion():number
Retrieve the major version of the KeplerCrypto Turbo Module.
Returns
number
number The major version number.
getMinorVersion()
staticgetMinorVersion():number
Retrieve the minor version of the KeplerCrypto Turbo Module.
Returns
number
number The minor version number.
getPatchVersion()
staticgetPatchVersion():number
Retrieve the patch version of the KeplerCrypto Turbo Module.
Returns
number
number The patch version number.
getRandom()
getRandom(length:
number):Promise<number[]>
Generate random data.
Parameters
length
number
The length in bytes of the random data to generate.
Throws
- If the length is invalid.
- If the random data generation fails.
Returns
Promise<number[]>
Promisenumber[] A promise resolving to an array of random bytes.
getSupportedAsymmetricCipherAlgorithms()
getSupportedAsymmetricCipherAlgorithms(): AsymmetricAlgorithm
[]
Get supported asymmetric cipher algorithms.
This function retrieves a list of all the supported asymmetric cipher algorithms.
Returns
AsymmetricAlgorithm[] An array of the supported asymmetric cipher algorithms.
getSupportedDigestAlgorithms()
getSupportedDigestAlgorithms(): DigestAlgorithm
[]
List all the supported digest algorithms.
This function returns an array of the supported digest algorithms. Users can iterate over this array to obtain information about each supported digest algorithm.
Returns
DigestAlgorithm[] An array of the supported digest algorithms.
getSupportedEccCurves()
getSupportedEccCurves(): EccCurve
[]
List the supported elliptic-curve cryptography (ECC) curves.
This function returns an array of all the supported elliptic-curve cryptography curves.
Returns
EccCurve[]
EccCurve[] An array of the supported ECC curves.
getSupportedSignatureAlgorithms()
getSupportedSignatureAlgorithms(): AsymmetricAlgorithm
[]
List the supported signature algorithms.
This function returns an array of all the supported signature algorithms.
Returns
AsymmetricAlgorithm[] An array of the supported signature algorithms.
getSupportedSymmetricAlgorithms()
getSupportedSymmetricAlgorithms(): SymmetricAlgorithm
[]
List all the supported symmetric algorithms.
This function provides a list of all the symmetric algorithms that are available in the system. The caller can use this list to determine which symmetric algorithms are supported.
Returns
SymmetricAlgorithm[] An array of the supported symmetric algorithms.
getSymmetricAlgorithmByName()
getSymmetricAlgorithmByName(name:
string): SymmetricAlgorithm
Get a symmetric algorithm by name.
This function retrieves a symmetric algorithm based on its name. The name parameter specifies the name of the algorithm to retrieve.
Parameters
name
string
The name of the symmetric algorithm to retrieve.
Throws
- If the algorithm name is invalid.
Returns
SymmetricAlgorithm The requested symmetric algorithm.
getWrappingSchemeByName()
getWrappingSchemeByName(name:
string): WrappingScheme
Get a wrapping scheme by name.
This function retrieves a wrapping scheme by its name.
Parameters
name
string
The name of the wrapping scheme.
Throws
- If the scheme name is invalid.
Returns
WrappingScheme The requested wrapping scheme.
makeAsymmetricCipherContextBuilder()
makeAsymmetricCipherContextBuilder(algorithm: AsymmetricAlgorithm): AsymmetricCipherContextBuilder
Create a builder for asymmetric cipher contexts.
This function creates an object that can be used to build cipher contexts using asymmetric cryptography.
Parameters
algorithm
The asymmetric algorithm to be used.
Throws
- If the given algorithm is not supported.
Returns
AsymmetricCipherContextBuilder
AsymmetricCipherContextBuilder A new builder for asymmetric cipher contexts.
makeAsymmetricKeyBuilder()
makeAsymmetricKeyBuilder(): AsymmetricKeyBuilder
Create a builder for asymmetric keys.
This function creates an object that can be used to build asymmetric keys.
Returns
AsymmetricKeyBuilder A new asymmetric key builder object.
makeCbcCipherContextBuilder()
makeCbcCipherContextBuilder(algorithm: SymmetricAlgorithm): CbcContextBuilder
Create a builder for cipher contexts in CBC mode.
This function creates an object that can be used to build a cipher context in CBC mode.
Parameters
algorithm
The symmetric algorithm to use.
Throws
- If the algorithm is invalid.
Returns
CbcContextBuilder A new CBC cipher context builder.
makeCtrCipherContextBuilder()
makeCtrCipherContextBuilder(algorithm: SymmetricAlgorithm): CtrContextBuilder
Create a builder for a cipher context in CTR (Counter) mode.
This function creates an object that can be used to build a cipher context in CTR mode.
Parameters
algorithm
The symmetric algorithm to use.
Throws
- If the algorithm is invalid.
Returns
CtrContextBuilder A new CTR cipher context builder.
makeDiffieHellmanKeyBuilder()
makeDiffieHellmanKeyBuilder():
DiffieHellmanKeyBuilder
Create a builder for Diffie-Hellman keys.
This function creates an object that can be used to build Diffie-Hellman keys.
Returns
DiffieHellmanKeyBuilder
DiffieHellmanKeyBuilder A new Diffie-Hellman key builder object.
makeDigestContextBuilder()
makeDigestContextBuilder(): DigestContextBuilder
Create a builder for digest (hash) contexts.
This function creates an object that can be used to build digest contexts
Returns
DigestContextBuilder A new builder for digest contexts.
makeEccKeyBuilder()
makeEccKeyBuilder():
EccKeyBuilder
Create a builder for elliptic-curve cryptography (ECC) keys.
This function creates an object that can be used to build ECC keys.
Returns
EccKeyBuilder
EccKeyBuilder A new ECC key builder object.
makeEcdhContextBuilder()
makeEcdhContextBuilder(): EcdhContextBuilder
Create a builder for ECDH key exchange contexts.
This function creates an object that can be used to build ECDH key exchange contexts.
EcdhContextBuilder A new builder for ECDH key exchange contexts.
Returns
makeGcmCipherContextBuilder()
makeGcmCipherContextBuilder(algorithm: SymmetricAlgorithm): GcmContextBuilder
Create a builder for cipher contexts in GCM mode.
This function creates an object that can be used to build a cipher context in GCM mode.
Parameters
algorithm
The symmetric algorithm to use.
Throws
- If the algorithm is invalid.
Returns
GcmContextBuilder A new GCM cipher context builder.
makeHkdfContextBuilder()
makeHkdfContextBuilder(): HkdfContextBuilder
Create a builder for HKDF key derivation contexts.
This function creates an object that can be used to build HKDF key derivation contexts.
HkdfContextBuilder A new builder for HKDF key derivation contexts.
Returns
makeHmacContextBuilder()
makeHmacContextBuilder(): HmacContextBuilder
Create a builder for HMAC (Hash-based Message Authentication Code) contexts.
This function creates an object that can be used to build HMAC contexts.
Returns
HmacContextBuilder A new builder for HMAC contexts.
makePbkdf2ContextBuilder()
makePbkdf2ContextBuilder(): Pbkdf2ContextBuilder
Create a builder for PBKDF2 key derivation contexts.
This function creates an object that can be used to build PBKDF2 key derivation contexts.
Pbkdf2ContextBuilder A new builder for PBKDF2 key derivation contexts.
Returns
makeRsaKeyBuilder()
makeRsaKeyBuilder(): RsaKeyBuilder
Create a builder for RSA keys.
This function creates an object that can be used to build RSA keys.
Returns
RsaKeyBuilder A new RSA key builder object.
makeRsaOaepCipherContextBuilder()
makeRsaOaepCipherContextBuilder(digestAlgorithm: DigestAlgorithm): RsaOaepContextBuilder
Create a builder for RSA-OAEP cipher contexts.
This function creates an object that can be used to build RSA-OAEP cipher contexts for asymmetric cryptography.
Parameters
digestAlgorithm
The digest algorithm to be used.
Throws
- If the digest algorithm is invalid.
Returns
RsaOaepContextBuilder A new builder for RSA-OAEP cipher contexts.
makeRsaOaepKeyBuilder()
makeRsaOaepKeyBuilder(): RsaOaepKeyBuilder
Creates a builder for RSA-OAEP keys.
This function creates an object that can be used to build RSA-OAEP keys.
Returns
RsaOaepKeyBuilder A new RSA-OAEP key builder object.
makeRsassaPkcs1ContextBuilder()
makeRsassaPkcs1ContextBuilder(): RsassaPkcs1ContextBuilder
Create a builder for an RSASSA-PKCS1-v1_5 signature context.
This function creates an object that can be used to build an RSASSA-PKCS1-v1_5 signature context.
Returns
RsassaPkcs1ContextBuilder A new builder for RSASSA-PKCS1-v1_5 signature contexts.
makeRsassaPssContextBuilder()
makeRsassaPssContextBuilder(): RsassaPssContextBuilder
Create a builder for an RSASSA-PSS signature context.
This function creates an object that can be used to build an RSASSA-PSS signature context.
Returns
RsassaPssContextBuilder A new builder for RSASSA-PSS signature contexts.
makeSignatureContextBuilder()
makeSignatureContextBuilder(): SignatureContextBuilder
Create a builder for a signature context.
This function creates an object that can be used to build a signature context.
Returns
SignatureContextBuilder A new signature context builder.
makeSymmetricKeyBuilder()
makeSymmetricKeyBuilder(): SymmetricKeyBuilder
Create a builder for symmetric keys.
This function creates an object that can be used to build symmetric keys.
Returns
SymmetricKeyBuilder A new symmetric key builder object.
Last updated: Jul 22, 2026

