aesCfbEncrypt(key: Uint8Array,data: Uint8Array): Uint8Array
Encrypts a body with AES-128-CFB, 128-bit segments, IV "0123456789abcdef".
Baichuan encrypts a message's extension and body separately, each starting from the IV, so call this once per part.
Encrypt and decrypt a body
Encrypt and decrypt a body
import { assertEquals } from "@std/assert"; import { aesCfbDecrypt, aesCfbEncrypt, } from "@hertzg/reolink-api/encoding/cipher"; const key = new TextEncoder().encode("08822D7143979103"); const plain = new TextEncoder().encode("hello"); const encrypted = aesCfbEncrypt(key, plain); assertEquals(encrypted, Uint8Array.of(0x06, 0x2c, 0x91, 0x2d, 0xd6)); assertEquals(aesCfbDecrypt(key, encrypted), plain);
key: Uint8Array
The 16-byte session key derived at login.
data: Uint8Array
The plaintext.
The ciphertext, the same length as data.