Index

src/functions/convertKetToBase64.ts

convertKetToBase64
convertKetToBase64(key: string)

Converts an RSA key to a base64-encoded string.

This function removes any leading spaces from each line of the key and then encodes it to base64 format.

Parameters :
Name Type Optional Description
key string No
  • The RSA key to be converted to base64. It may contain leading spaces in each line.
Returns : string

The base64-encoded version of the RSA key.

src/functions/createPrivateAndPublicKeys.ts

createPrivateAndPublicKeys
createPrivateAndPublicKeys(modulusLength: number)

Generates a pair of RSA private and public keys with the specified modulus length.

If the crypto.generateKeyPairSync function is available, it generates the keys using the provided modulus length, otherwise, it returns empty strings for both keys.

Parameters :
Name Type Optional Default value Description
modulusLength number No 2048
  • The length of the RSA modulus in bits. Defaults to 2048 bits.
Returns : returnCreateKeys

An object containing the generated RSA public and private keys in PEM format.

src/functions/decrypt.ts

decrypt
decrypt(args: parametersOfDecryptPublic)

Decrypts a base64-encoded string using an RSA public key.

The function first decodes the provided RSA public key and the base64-encoded text, then decrypts the text using the RSA public key.

Parameters :
Name Type Optional Description
args parametersOfDecryptPublic No
  • An object containing the text to decrypt and the RSA public key.
Returns : string

The decrypted string in UTF-8 format.

src/functions/decryptStringWithRsaPrivateKey.ts

decryptStringWithRsaPrivateKey
decryptStringWithRsaPrivateKey(args: parametersOfDecrypt)

Decrypts a base64-encoded string using an RSA private key.

This function decodes the provided RSA private key, then uses it to decrypt the base64-encoded string.

Parameters :
Name Type Optional Description
args parametersOfDecrypt No
  • An object containing the text to decrypt and the RSA private key.
Returns : string

The decrypted string in UTF-8 format.

src/functions/encrypt.ts

encrypt
encrypt(args: parametersOfEncryptPrivate)

Encrypts a string using an RSA private key.

This function encodes the provided RSA private key, converts the input text to a buffer, and encrypts it using the private key. The result is returned as a base64-encoded string.

Parameters :
Name Type Optional Description
args parametersOfEncryptPrivate No
  • An object containing the text to encrypt and the RSA private key.
Returns : string

The encrypted string in base64 format.

src/functions/encryptStringWithRsaPublicKey.ts

encryptStringWithRsaPublicKey
encryptStringWithRsaPublicKey(args: parametersOfEncrypt)

Encrypts a string using an RSA public key.

This function decodes the provided RSA public key, converts the input text into a buffer, and encrypts it using the public key. The encrypted result is returned as a base64-encoded string.

Parameters :
Name Type Optional Description
args parametersOfEncrypt No
  • An object containing the text to encrypt and the RSA public key.
Returns : string

The encrypted string in base64 format.

results matching ""

    No results matching ""