@lzwme/fe-utils
    Preparing search index...

    Function aesEncrypt

    • aes 加密

      Parameters

      • data: unknown
      • key: BinaryLike
      • algorithm: string = 'aes-128-ecb'
      • iv: BinaryLike | null = null
      • salt: string = ''

      Returns Buffer<ArrayBuffer>

      // 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);