# @jihyunlab/web-crypto

> JihyunLab Web crypto.

Latest version **1.1.0** (published 2025-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jihyunlab/web-crypto
pnpm add @jihyunlab/web-crypto
yarn add @jihyunlab/web-crypto
bun add @jihyunlab/web-crypto
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2025-11-07 |
| First published | 2024-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | JihyunLab |
| Maintainers | jihyunlab-dev, jihyunlab-phil, jihyunlab-donghyun, jihyunlab-dh, jihyunlab-jh, jihyunlab-jmin |
| Keywords | web-crypto, web, crypto, cipher, encryption, decryption, aes-cbc, aes-gcm |

## Links

- npm: https://www.npmjs.com/package/@jihyunlab/web-crypto
- Repository: https://github.com/jihyunlab/web-crypto
- Homepage: https://jihyunlab.com/library/npm/web-crypto
- Issues: https://github.com/jihyunlab/web-crypto/issues
- npm.io page: https://npm.io/package/@jihyunlab/web-crypto

## Dependencies (1)

- [@jihyunlab/web-buffer](https://npm.io/package/@jihyunlab/web-buffer.md) ^1.0.1

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2025-11-07
- 1.0.13 — 2024-07-17
- 1.0.12 — 2024-07-14
- 1.0.11 — 2024-07-14
- 1.0.10 — 2024-07-13
- 1.0.9 — 2024-07-13
- 1.0.8 — 2024-07-13
- 1.0.7 — 2024-07-13
- 1.0.6 — 2024-07-13
- 1.0.5 — 2024-07-12
- 1.0.4 — 2024-07-12
- 1.0.3 — 2024-07-12
- 1.0.2 — 2024-07-12
- 1.0.1 — 2024-07-12
- 1.0.0 — 2024-07-12

## README

# @jihyunlab/web-crypto

[![Version](https://img.shields.io/npm/v/@jihyunlab/web-crypto.svg?style=flat-square)](https://www.npmjs.com/package/@jihyunlab/web-crypto?activeTab=versions) [![Downloads](https://img.shields.io/npm/dt/@jihyunlab/web-crypto.svg?style=flat-square)](https://www.npmjs.com/package/@jihyunlab/web-crypto) [![Last commit](https://img.shields.io/github/last-commit/jihyunlab/web-crypto.svg?style=flat-square)](https://github.com/jihyunlab/web-crypto/graphs/commit-activity) [![License](https://img.shields.io/github/license/jihyunlab/web-crypto.svg?style=flat-square)](https://github.com/jihyunlab/web-crypto/blob/master/LICENSE) [![Linter](https://img.shields.io/badge/linter-eslint-blue?style=flat-square)](https://eslint.org) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\
[![Build](https://github.com/jihyunlab/web-crypto/actions/workflows/build.yml/badge.svg)](https://github.com/jihyunlab/web-crypto/actions/workflows/build.yml) [![Lint](https://github.com/jihyunlab/web-crypto/actions/workflows/lint.yml/badge.svg)](https://github.com/jihyunlab/web-crypto/actions/workflows/lint.yml) [![codecov](https://codecov.io/gh/jihyunlab/web-crypto/graph/badge.svg?token=UW73ZNZY03)](https://codecov.io/gh/jihyunlab/web-crypto)

@jihyunlab/web-crypto was developed to enhance the convenience of implementing cryptographic functionalities in web applications.

The encryption function is implemented with [Web Crypto API](https://nodejs.org/api/webcrypto.html) in Node.js and provides encryption for AES 256 CBC and AES 256 GCM.

## Installation

```bash
npm i @jihyunlab/web-crypto
```

## Usage

You can easily encrypt and decrypt data with a simple method.

```
import { CIPHER, createCipher } from '@jihyunlab/web-crypto';

const cipher = await createCipher(CIPHER.AES_256_GCM, 'your secret key');

const encrypted = await cipher.encrypt('jihyunlab');
console.log(encrypted); // Uint8Array(37)[51, 174, 20, 84, 12, 141, 173, 206, 249, 11, 59, 112, 88, 223, 163, 211, 128, 234, 102, 116, 16, 224, 175, 45, 46, 52, 186, 141, 15, 243, 9, 120, 64, 27, 135, 169, 65]

const decrypted = await cipher.decrypt(encrypted);
console.log(decrypted); // Uint8Array(9)[106, 105, 104, 121, 117, 110, 108, 97, 98]
```

Provides encryption functionality for Uint8Array data.

```
const encrypted = await cipher.encrypt(
  new Uint8Array([106, 105, 104, 121, 117, 110, 108, 97, 98])
);
console.log(encrypted); // Uint8Array(37)[185, 95, 254, 103, 109, 250, 109, 50, 8, 218, 251, 74, 215, 108, 74, 86, 177, 82, 144, 154, 156, 120, 128, 169, 112, 236, 153, 23, 253, 164, 238, 159, 236, 17, 85, 26, 75]

const decrypted = await cipher.decrypt(encrypted);
console.log(decrypted); // Uint8Array(9)[106, 105, 104, 121, 117, 110, 108, 97, 98]
```

You can configure encryption options such as salt and iteration.

```
const cipher = await createCipher(CIPHER.AES_256_GCM, 'your secret key', {
  salt: 'salt',
  iterations: 256,
});
```

Provides hashing functionality for Uint8Array data.

```
import { HASH, createHash } from '@jihyunlab/web-crypto';

const hash = await createHash(HASH.SHA_256);

const hashed = await hash.digest(
  new Uint8Array([106, 105, 104, 121, 117, 110, 108, 97, 98])
);
console.log(hashed); // Uint8Array(32) [200, 111, 45, 209, 157, 58, 63, 244, 241, 200, 144, 165, 32, 243, 10, 145, 101, 204, 44, 179, 226, 63, 57, 208, 185, 93, 101, 0, 122, 198, 82, 100]
```

## @jihyunlab/web-buffer

You can install [@jihyunlab/web-buffer](https://www.npmjs.com/package/@jihyunlab/web-buffer) to perform additional data conversions.

```
npm i @jihyunlab/web-buffer
```

```
import { WebBuffer } from '@jihyunlab/web-buffer';

const buffer = WebBuffer.from(
  new Uint8Array([106, 105, 104, 121, 117, 110, 108, 97, 98]),
  'uint8array' /* hex, base64, base64url, utf8, uint8array */
);

const utf8 = buffer.toString('utf8');
console.log(utf8); // jihyunlab
```

## @jihyunlab/crypto

[@jihyunlab/crypto](https://www.npmjs.com/package/@jihyunlab/crypto) implements encryption functionalities for Node.js applications using the same interface as @jihyunlab/web-crypto.

Consider using @jihyunlab/crypto for decrypting encrypted data from @jihyunlab/web-crypto in Node.js applications, or vice versa.

```
import { CIPHER, createCipher } from '@jihyunlab/crypto';

const cipher = await createCipher(CIPHER.AES_256_GCM, 'your secret key');
const encrypted = await cipher.encrypt('jihyunlab');
```

## Credits

Authored and maintained by JihyunLab <<info@jihyunlab.com>>

## License

Open source [licensed as MIT](https://github.com/jihyunlab/web-crypto/blob/master/LICENSE).

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