@groww-tech/encryption
Version:
Encryption service as name suggests provides encryption, decryption facility with all major algorithms in trend.
82 lines (79 loc) • 2.28 kB
TypeScript
export { default as Utf8Encoder } from 'crypto-js/enc-utf8';
export { default as Base64Encoder } from 'crypto-js/enc-base64';
export { default as NoPadding } from 'crypto-js/pad-nopadding';
export { default as sha256Hash } from 'crypto-js/sha256';
import { ResponseType, CipherOptionType } from './types';
/**
* Encrypt
*
* @remarks
* This method is a part of our Encryption Service.
*
* @param object - The data that needs to be encrypted in AES
* @param secretKey - The key used for encrytping the data.
*
* @returns The object with keys of data and error.
*
* @example
* ```
* encryptAes('Data to encrypt','secret-key')); => Output will be
* {
* data:'##Some random ciphered text',
* error:null
* }.
* ```
*/
declare const encryptAes: (dataToEncrypt: object | string, ENCODE: string) => ResponseType;
/**
* Encrypt
*
* @remarks
* This method is used by encryption service .
*
* @param dataToEncrypt - The data that needs to be encrypted in AES
* @param ENCODE - The key used for encrytping the data.
* @param cipherOptions - The options for encrypting the data using aes algorithm.
*
* @returns The object with keys of data and error.
*
* @example
* ```
* encryptAes('Data to encrypt','secret-key')); => Output will be
* {
* data:'##Some random ciphered text',
* error:null
* }.
* ```
*/
declare const encryptAesBase64: (dataToEncrypt: string, ENCODE: string | CryptoJS.lib.WordArray, cipherOptions: CipherOptionType) => ResponseType;
/**
* Decrypt
*
* @remarks
* This method is a part of our Encryption Service.
*
* @param object - The encrypted data (in AES) that needs to be decrypted
* @param secretKey - The key used for decrypting the data.
*
* @returns The object with keys of data and error.
*
* @example
* ```
* decryptAes('##Some randome ciphered data','secret-key'))
* Output will be
* {
* data:'The original data that was encrypted',
* error:null
* }.
*
* Note: if in any case there was error in encrytping/decrypting the error key will be populated and data key will be null
* like
* {
* data:null,
* error:'Some error message'
* }
* ```
*
*/
declare const decryptAes: (ciphertext: string | null, ENCODE: string) => ResponseType;
export { decryptAes, encryptAes, encryptAesBase64 };