A minimal JavaScript and WebAssembly port of OpenSSL for web browsers.
OpenSSL-WASM-JS provides a lightweight, browser-compatible implementation of OpenSSL cryptographic functions through WebAssembly. This library enables secure cryptographic operations directly in the browser with performance close to native code.
- Lightweight: Minimized JavaScript wrapper with optimized WebAssembly binary
- Comprehensive: Supports essential OpenSSL cryptographic functions
- Browser-compatible: Works in all modern browsers that support WebAssembly
- Easy to use: Simple JavaScript API for common cryptographic operations
- Secure: Preserves the security properties of OpenSSL
npm install openssl-wasm-js
Or include directly in your HTML:
<script src="https://cdn.example.com/openssl-wasm-js/dist/openssl.min.js"></script>
To set up the development environment:
# Clone the repository
git clone https://github.com/yourusername/openssl-wasm-js.git
cd openssl-wasm-js
# Run the automated setup script
npm run setup
# Or set up manually
npm install
See the Setup Guide for detailed instructions.
// Basic usage
const opensslWasm = await OpenSSLWasm.initialize();
// Generate a random key
const key = opensslWasm.randomBytes(32);
// AES encryption
const encrypted = opensslWasm.aesEncrypt(data, key, iv);
// SHA-256 hash
const hash = opensslWasm.sha256(data);
// RSA operations
const { publicKey, privateKey } = opensslWasm.generateRsaKeyPair(2048);
const signature = opensslWasm.rsaSign(data, privateKey);
const isValid = opensslWasm.rsaVerify(data, signature, publicKey);
See the documentation for complete API details and the examples directory for more usage examples.
- Node.js (v14+)
- Emscripten SDK (we include it as a submodule)
- CMake (3.14+)
- Python (3.6+)
-
Clone the repository:
git clone https://github.com/yourusername/openssl-wasm-js.git cd openssl-wasm-js
-
Install dependencies:
npm install
-
Build the project:
npm run build
The build process will:
- Download and patch OpenSSL
- Compile OpenSSL to WebAssembly using Emscripten
- Generate the JavaScript wrapper
- Create optimized and minified distribution files
This project is licensed under the MIT License - see the LICENSE file for details.
OpenSSL is licensed under the Apache License 2.0. See OpenSSL License for details.