# @types/secret-blob

> TypeScript definitions for secret-blob

Latest version **1.1.3** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/secret-blob
pnpm add @types/secret-blob
yarn add @types/secret-blob
bun add @types/secret-blob
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2023-11-07 |
| First published | 2022-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/secret-blob
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/secret-blob
- npm.io page: https://npm.io/package/@types/secret-blob

## Dependencies (2)

- [@types/node](https://npm.io/package/@types/node.md) *
- [@types/sodium-native](https://npm.io/package/@types/sodium-native.md) *

## Recent versions

- 1.1.3 (latest) — 2023-11-07
- 1.1.0 (ts4.0) — 2022-08-29
- 1.1.2 — 2023-10-18
- 1.1.1 — 2023-09-25

## README

# Installation
> `npm install --save @types/secret-blob`

# Summary
This package contains type definitions for secret-blob (https://github.com/emilbayes/secret-blob).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/secret-blob.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/secret-blob/index.d.ts)
````ts
/// <reference types="node" />
import { SecureBuffer } from "sodium-native";

/**
 * Generate a new key.
 *
 * @param key The buffer to write the key to. Must be `KEYBYTES` long.
 *
 * @example
 * import * as secretBlob from 'secret-blob'
 *
 * const key = secretBlob.keygen()
 */
export function keygen<TBuf extends Buffer = SecureBuffer>(key?: TBuf): TBuf;
/**
 * Encrypt `plaintext` under `key`.
 *
 * @param plaintext The plaintext to encrypt.
 * @param key The key to use for encryption.
 * @param ciphertext The buffer to write `ciphertext` to. Must be `encryptLength(plaintext)` long.
 *
 * @example
 * import * as secretBlob from 'secret-blob'
 *
 * const key = secretBlob.keygen()
 * const message = Buffer.from('Hello world')
 * const encrypted = secretBlob.encrypt(message, key)
 */
export function encrypt(plaintext: Buffer, key: Buffer, ciphertext?: Buffer): Buffer;
/**
 * @returns The number of bytes required to encrypt plaintext. Simply `plaintext.byteLength + HEADERBYTES`.
 */
export function encryptLength(plaintext: Buffer): number;
/**
 * Decrypt `ciphertext` under `key`.
 *
 * @param ciphertext The ciphertext to decrypt.
 * @param key The key to use for decryption.
 * @param plaintext The buffer to write `plaintext` to. Must be `decryptLength(plaintext)` long.
 *
 * @example
 * import * as secretBlob from 'secret-blob'
 *
 * const key = secretBlob.keygen()
 * const message = Buffer.from('Hello world')
 * const encrypted = secretBlob.encrypt(message, key)
 * const decrypted = secretBlob.decrypt(encrypted, key)
 * console.log(decrypted.toString()) // Hello world
 */
export function decrypt<TBuf extends Buffer = SecureBuffer>(ciphertext: Buffer, key: Buffer, plaintext?: TBuf): TBuf;
/**
 * @returns The number of bytes required to encrypt ciphertext. Simply `ciphertext.byteLength - HEADERBYTES`.
 */
export function decryptLength(ciphertext: Buffer): number;

/** Byte length of a key. */
export const KEYBYTES: number;
/** Byte length of the header added to ciphertext. */
export const HEADERBYTES: number;

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 15:11:36 GMT
 * Dependencies: [@types/node](https://npmjs.com/package/@types/node), [@types/sodium-native](https://npmjs.com/package/@types/sodium-native)

# Credits
These definitions were written by [BendingBender](https://github.com/BendingBender).

---
_Source: https://npm.io/package/@types/secret-blob · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
