UNPKG

strong-cryptor

Version:
46 lines (45 loc) 2.59 kB
/// <reference types="node" /> import { IEncryptionOptionsClassBase } from './typings'; export declare class Encryptor { private options; /** * Create new instance of encryptor * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data, please store it in the safe places * @param {IEncryptionOptions} options (encryption options, see [[IEncryptionOptions]] for more details */ constructor(options: IEncryptionOptionsClassBase); /** * set key for encryption 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 encryption process * @param {IEncryptionOptions} options (encryption options, see [[IEncryptionOptions]] for more details */ setOptions(options: Partial<IEncryptionOptionsClassBase>): void; /** * encrypt the given text with aes-256-cbc encryption algorithm * @param {string | Buffer} data string or Buffer that will be encrypted * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data, please store it in the safe places * @param {IEncryptionOptions} options encryption options, see [[IEncryptionOptions]] for more details * @returns {string} return encrypted string with selected encoding */ encrypt(data: string | Buffer, options?: Partial<IEncryptionOptionsClassBase>): string; /** * encrypt the given text with aes-256-cbc encryption algorithm * @param {string} pathToFile string of file path * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data, please store it in the safe places * @param {IEncryptionOptions} options encryption options, see [[IEncryptionOptions]] for more details * @returns {string} return encrypted string with selected encoding */ encryptFile(pathToFile: string, options?: Partial<IEncryptionOptionsClassBase>): string; /** * encrypt the given text with aes-256-cbc encryption algorithm * @param {string|Buffer} data string or buffer that will be encrypted * @param {string} key (or secret) is 256bits (32 charcters) that used to encrypt dan decrypt the data, please store it in the safe places * @param {Encoding} encoding string/text encoding you can choose `base64`(default) or `hex` * @returns {string} return encrypted string with selected encoding */ private encryptor; }