UNPKG

@xtsai/xai-utils

Version:

The xai-utils is an openai nodejs sdk compatible extension library.

37 lines (36 loc) 980 B
import { AESOptionsType } from './crypto-types'; export declare const AES_KEY_LENGTH = 32; export declare const AES_ALGORITHM_CBC = "aes-256-cbc"; /** * * @returns */ export declare function genRandomAppKey(): string; export declare class AESCipher { protected alg: string; private readonly key; private readonly iv; constructor(appKey: string); get opts(): AESOptionsType; get hexOpts(): AESOptionsType; /** * * @param text * @returns string */ encode(text: string): string; /** * utf8 * @param encryptedData hex * @returns string utf8 */ decode(encryptedData: any): string; static parseAppKey(appKey: string): { key: Buffer<ArrayBufferLike>; iv: Buffer<ArrayBufferLike>; }; static fromBase64(base64: string): Buffer; static fromBase64ToHex(base64: string): string; static hexToBase64(hex: string): string; static newInstance(appKey: string): AESCipher; }