UNPKG

strong-cryptor

Version:
48 lines (47 loc) 3.08 kB
import { BufferAndString, IDecryptionOptionsClassBase, IToBufferOptions } from './typings'; export declare class Decryptor { private options; constructor(options: IDecryptionOptionsClassBase); /** * set key for decryption process * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data, please store it in the safe places */ setKey(key: string): void; /** * set options for decryption process * @param {IDecryptionOptionsClassBase} options (decryption options, see [[IDecryptionOptionsClassBase]] for more details */ setOptions(options: Partial<IDecryptionOptionsClassBase>): void; /** * decrypt the encrypted data from strong-cryptor * @param {string} encryptedData encrypted string * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data (must be same with the encryption process), please store it in the safe places * @param {IDecryptionOptionsClassBase} options decryption options, see [[IDecryptionOptionsClassBase]] for more details * @returns {string|Buffer} return decrypted string/Buffer */ decrypt<T extends Required<IToBufferOptions>>(encryptedString: string, options?: Partial<T> & Partial<IDecryptionOptionsClassBase>): BufferAndString<T>; /** * decrypt file that already encrypted from strong-cryptor * @param {string} filePath path to file * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data (must be same with the encryption process), please store it in the safe places * @param {IDecryptionOptionsClassBase} options decryption options, see [[IDecryptionOptionsClassBase]] for more details * @returns {string|Buffer} return decrypted string/Buffer */ decryptFile<T extends Required<IToBufferOptions>>(filePath: string, options?: Partial<T> & Partial<IDecryptionOptionsClassBase>): BufferAndString<T>; /** * decrypt the encrypted data from strong-cryptor to string * @param {string} encryptedData encrypted string * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data (must be same with the encryption process), please store it in the safe places * @param {Encoding} encoding string/text encoding you can choose `base64`(default) or `hex` (must be same with the encryption process) * @returns {string} return decrypted string */ private stringDecryptor; /** * decrypt the encrypted data from strong-cryptor to Buffer * @param {string} encryptedData encrypted string * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data (must be same with the encryption process), please store it in the safe places * @param {Encoding} encoding string/text encoding you can choose `base64`(default) or `hex` (must be same with the encryption process) * @returns {Buffer} return decrypted data as a Buffer */ private bufferDecryptor; }