function aesCfbEncrypt
aesCfbEncrypt(): 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.

Examples

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

Parameters

The 16-byte session key derived at login.

The plaintext.

Return Type

The ciphertext, the same length as data.

Usage

import { aesCfbEncrypt } from "encoding/cipher.ts";