Skip to content

weixin-ts / cdn/src / encryptAesEcb

Function: encryptAesEcb()

encryptAesEcb(plaintext, key): Promise<Uint8Array<ArrayBufferLike>>

Defined in: cdn/src/aes-ecb.ts:92

Encrypt data using AES-128-ECB. Simulated via AES-CBC with zero IV, one block at a time.

Parameters

plaintext

Uint8Array

Data to encrypt (will be PKCS7-padded automatically)

key

Uint8Array

16-byte AES key

Returns

Promise<Uint8Array<ArrayBufferLike>>

Encrypted ciphertext

Example

ts
const key = crypto.getRandomValues(new Uint8Array(16))
const encrypted = await encryptAesEcb(data, key)

Released under the MIT License.