8000 GitHub - hkalbertl/wcipher: WCipher is a TypeScript library that leverages the native Web Crypto API for robust and secure encryption and decryption. Designed with ease of use in mind, it offers seamless integration into your applications while ensuring top-notch security.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WCipher is a TypeScript library that leverages the native Web Crypto API for robust and secure encryption and decryption. Designed with ease of use in mind, it offers seamless integration into your applications while ensuring top-notch security.

License

Notifications You must be signed in to change notification settings

hkalbertl/wcipher

Repository files navigation

WCipher

WCipher is a TypeScript library that leverages the native Web Crypto API for robust and secure encryption and decryption. Designed with ease of use in mind, it offers seamless integration into your applications while ensuring top-notch security.

Features

  • Password-Based Key Derivation: Encryption keys are derived securely from user-provided passwords using the PBKDF2 (Password-Based Key Derivation Function 2) algorithm.
  • AES-GCM Encryption: Plain data is encrypted using the AES-GCM (Advanced Encryption Standard - Galois/Counter Mode) algorithm, providing both confidentiality and integrity.
  • Comprehensive Encryption Result: The final encryption output includes the key salt, initialization vector (IV), and encrypted data, all combined into a single package for convenience and security.

Data Structure

The combined encrypted content contains:

  • 16 bytes of key salt, generated by using crypto.getRandomValues
  • 12 bytes of initialization vector (IV), generated by using crypto.getRandomValues
  • Variable length of encrypted data + AES Auth Tags

Installation

You can install WCipher via NPM or Yarn:

# Using NPM
npm install wcipher

# Using Yarn
yarn add install wcipher

# Using PNPM
pnpm add wcipher

Example 1: Encryption

// Import library
import WCipher from "wcipher";

// Convert plain text to byte array
const plainTextData = "Plain text data...";
const plainTextBytes = new TextEncoder().encode(plainTextData);

// Encrypt data
const encryptedData = await WCipher.encrypt(
  "A_SUper-Strong!P@ssw0rd", plainTextBytes);

Example 2: Decryption

// Import library
import WCipher from "wcipher";

// Convert plain text to byte array
const encryptedData = /* Prepare the encrypted data in Uint8Array */;

// Decrypt data
const originalData = await WCipher.decrypt(
  "A_SUper-Strong!P@ssw0rd", encryptedData);

// Optional: If the original data is text,
// convert the data back to text by using TextDecoder.
const plainTextData = new TextDecoder().decode(originalData);
console.log("Original text: " + plainTextData);

License

Licensed under the MIT license.

About

WCipher is a TypeScript library that leverages the native Web Crypto API for robust and secure encryption and decryption. Designed with ease of use in mind, it offers seamless integration into your applications while ensuring top-notch security.

Topics

Resources

License

Stars

Watchers

Forks

0