UNPKG

@qlover/corekit-node

Version:
65 lines (64 loc) 1.9 kB
/// <reference types="node" /> import type { Encryptor } from '@qlover/fe-corekit'; /** * String encryption implementation with Zlib compression * Combines AES encryption with data compression * * Features: * - AES-128-CBC encryption * - Zlib compression * - IV support * - Configurable encoding * * @implements {Encryptor<string, string>} * * @example * ```typescript * const encryptor = new StringZlibEncrypt('my-16-char-key!!'); * * // Encrypt and compress * const encrypted = encryptor.encrypt('large text data'); * * // Decrypt and decompress * const decrypted = encryptor.decrypt(encrypted); * ``` */ export declare class StringZlibEncrypt implements Encryptor<string, string> { private readonly encoding; private ALGORITHM; private KEY; private IV_LENGTH; private KEY_LENGTH; /** * Creates a new StringZlibEncrypt instance * @param encryptionKey - Key used for encryption/decryption * @param encoding - Output encoding format * @throws {RangeError} If key length is invalid */ constructor(encryptionKey: string, encoding?: globalThis.BufferEncoding); /** * Validates and processes encryption key * Ensures key meets length requirements * * @param key - Raw encryption key * @returns Validated key buffer * @throws {RangeError} If key length is invalid */ private validateKey; /** * Encrypts and compresses a string value * Applies compression before encryption * * @param value - String to encrypt * @returns Encrypted and compressed string with IV */ encrypt(value: string): string; /** * Decrypts and decompresses an encrypted string * Applies decryption before decompression * * @param encryptedData - Encrypted string with IV * @returns Original string */ decrypt(encryptedData: string): string; }