@tiny-utils/crypto
Version:
Tiny utils for crypto: asymmetric/symmetric encryption, ed25519, sha256, etc.
37 lines (36 loc) • 1.29 kB
TypeScript
/**
* @category Crypto
* @description Method to symmetrically encrypt the data using *xsalsa20-poly1305* algorithm.
*
* @param data Data to encrypt
* @param key Symmetric key to encrypt the data
* @returns Encrypted data
*/
export declare const symmetricEncrypt: (data: Uint8Array, key: Uint8Array) => Uint8Array<ArrayBufferLike>;
/**
* Method to pack data and nonce into one readable bytes array
*
* @param encData Encrypted data raw bytes
* @param nonce Nonce raw bytes
* @returns Container buffer
*/
export declare const packSymmetricalyEncryptedData: (encData: Uint8Array, nonce: Uint8Array) => Uint8Array<ArrayBufferLike>;
/**
* @category Crypto
* @description Method to symmetrically decrypt the data using *xsalsa20-poly1305* algorithm.
*
* @param data Data to decrypt
* @param key Symmetric key to decrypt the data
* @returns Decrypted data
*/
export declare const symmetricDecrypt: (data: Uint8Array, key: Uint8Array) => Uint8Array<ArrayBufferLike>;
/**
* Method to unpack data and nonce from one readable bytes array
*
* @param data Bytes with encrypted data and nonce
* @returns Data and nonce
*/
export declare const unpackSymmetricalyEncryptedData: (data: Uint8Array) => {
nonce: Uint8Array<ArrayBuffer>;
encData: Uint8Array<ArrayBuffer>;
};