import { type BinaryLike, type BinaryToTextEncoding } from 'node:crypto'; /** 生成指定长度的字符串 */ export declare function genRandomAesKey(len?: number): string; interface HashFn { (algorithm: string, str: string | Buffer, isFile?: boolean, outputEncoding?: BinaryToTextEncoding): string; hashes?: Set; } /** * 生成指定字符串或指定文件路径的 hash 编码 * @param algorithm hash 编码算法 * @param str 指定的字符串,或者指定的文件路径 * @param isFile str 是否为一个文件路径 * @param outputEncoding 输出内容编码。默认为 hex */ export declare const hash: HashFn; /** * 生成指定字符串或指定文件路径的 sha256 编码摘要 * {@link hash} */ export declare function sha256(str: string | Buffer, isFile?: boolean, outputEncoding?: BinaryToTextEncoding): string; /** * 生成指定字符串或指定文件路径的md5值 * {@link hash} */ export declare function md5(str: string | Buffer, isFile?: boolean, outputEncoding?: BinaryToTextEncoding): string; export declare function md5ByFileStream(filepath: string): Promise; /** * 根据 Object 类型的参数值生成 md5 * @param params * @param filterKeyList 要过滤的通用字段 */ export declare function getMd5ByPlainObject(params: Record, filterKeyList?: string[]): string; /** * 基于 compressing 库的目录压缩 * @param srcDir 要压缩的目录路径 * @param dest 压缩文件输出路径。若省略则默认使用 srcDir 压缩目录名 * @param type 压缩类型 * @param includeDirName 是否包含 srcDir 目录名称。默认为 false */ export declare function compressing(srcDir: string, dest?: string, type?: 'zip' | 'gz' | 'tar', includeDirName?: boolean): Promise; /** * tar.gz 压缩。需添加依赖库 `compressing` * @param srcDir 要压缩的目录路径 * @param dest 压缩文件输出路径。若省略则默认使用 srcDir 压缩目录名 */ export declare function tgzip(srcDir: string, dest?: string, includeDirName?: boolean): Promise; /** * tar.gz 文件解压。需添加依赖库 `compressing` * @param srcFilePath 要解压的 tar.gz 文件路径 * @param dest 解压输出目录路径 */ export declare function untgzip(srcFilePath: string, dest?: string): Promise; /** * zip 压缩。需添加依赖库 `compressing` * @param srcDir 要压缩的目录路径 * @param dest zip 文件输出目录路径 */ export declare function zip(srcDir: string, dest?: string, includeDirName?: boolean): Promise; /** * zip 文件解压。需添加依赖库 `compressing` * @param srcFilePath 要解压的 tar.gz 文件路径 * @param dest 解压输出目录路径 */ export declare function unzip(srcFilePath: string, dest?: string): Promise; /** * aes 加密 * @example * ```ts * // default aes-128-ecb * const data = { a: 1, b: [1, 2, 3] }; * const key = '1234567812345678'; * const encrypted = aesEncrypt(data, key); * const decrypted = aesDecrypt(encrypted, key).toString('utf8'); * console.log('encrypted:', encrypted, 'decrypted: ', decrypted); * * // aes-128-cbc * const data = { a: 1, b: [1, 2, 3] }; * const key = '1234567812345678'; * const iv = Buffer.alloc(16, 0); * const algorithm = 'aes-128-cbc'; * const encrypted = aesEncrypt(data, key, algorithm, iv); * const decrypted = aesDecrypt(encrypted, key, algorithm, iv).toString('utf8'); * console.log('encrypted:', encrypted, 'decrypted: ', decrypted); * ``` */ export declare function aesEncrypt(data: unknown, key: BinaryLike, algorithm?: string, iv?: BinaryLike | null, salt?: string): Buffer; /** aes 解密 */ export declare function aesDecrypt(data: unknown, key: BinaryLike, algorithm?: string, iv?: BinaryLike | null, salt?: string): Buffer; export {};