# CryptoCipherBinding

`import { CryptoCipherBinding } from "destack:crypto/binding";`

Cipher binding family.

```ds title="CryptoCipherBinding"
export interface CryptoCipherBinding {
    encryptCipher(key: CryptoKeyHandle, parameters: &'b readonly CryptoCipherParameters<'a>, payload: &'c readonly [uint8]): Result<CryptoCipherOutput, HostError>;
    decryptCipher(key: CryptoKeyHandle, parameters: &'b readonly CryptoCipherParameters<'a>, payload: &'c readonly [uint8]): Result<uint8[], HostError>;
    openCipher(key: CryptoKeyHandle, direction: CryptoCipherDirection, parameters: &'b readonly CryptoCipherParameters<'a>): Result<CryptoCipherHandle, HostError>;
    updateCipherAdditionalData(cipher: CryptoCipherHandle, additionalData: &'a readonly [uint8]): Result<void, HostError>;
    updateCipher(cipher: CryptoCipherHandle, payload: &'a readonly [uint8]): Result<uint8[], HostError>;
    finishCipher(cipher: CryptoCipherHandle, finalPayload: &'a readonly [uint8]): Result<CryptoCipherOutput, HostError>;
    closeCipher(cipher: CryptoCipherHandle): Result<void, HostError>;
}
```

[language/library/src/crypto/binding/cipher.ds:42:133](https://github.com/destack-sh/destack/blob/main/language/library/src/crypto/binding/cipher.ds#L42-L133)

## Members

### `encryptCipher(key: CryptoKeyHandle, parameters: &'b readonly CryptoCipherParameters<'a>, payload: &'c readonly [uint8]): Result<CryptoCipherOutput, HostError>`

Encrypt one payload in one shot.

### `decryptCipher(key: CryptoKeyHandle, parameters: &'b readonly CryptoCipherParameters<'a>, payload: &'c readonly [uint8]): Result<uint8[], HostError>`

Decrypt one payload in one shot.

### `openCipher(key: CryptoKeyHandle, direction: CryptoCipherDirection, parameters: &'b readonly CryptoCipherParameters<'a>): Result<CryptoCipherHandle, HostError>`

Open one streaming cipher context.

### `updateCipherAdditionalData(cipher: CryptoCipherHandle, additionalData: &'a readonly [uint8]): Result<void, HostError>`

Add authenticated data to one streaming cipher context.

### `updateCipher(cipher: CryptoCipherHandle, payload: &'a readonly [uint8]): Result<uint8[], HostError>`

Update one streaming cipher context with one payload chunk.

### `finishCipher(cipher: CryptoCipherHandle, finalPayload: &'a readonly [uint8]): Result<CryptoCipherOutput, HostError>`

Finalize one streaming cipher context.

### `closeCipher(cipher: CryptoCipherHandle): Result<void, HostError>`

Close one streaming cipher context.
