crypto-engine-aes
v1.0.3
Published
Hybrid cryptography utilities for Node.js using RSA-OAEP and AES-GCM
Maintainers
Readme
crypto-engine 🔐
Hybrid cryptography utilities for Node.js designed for secure API communication. This package combines RSA-OAEP for secure key exchange and AES-GCM for authenticated payload encryption, following modern cryptographic best practices.
This package is designed for secure API communication where:
- AES-GCM is used to encrypt request/response payloads
- RSA-OAEP is used to encrypt the AES key
Features
- RSA encryption using OAEP (SHA-256 + MGF1 SHA-1)
- AES-GCM encryption (128 / 192 / 256 bit)
- Authenticated encryption (confidentiality + integrity)
- Base64-friendly output for APIs
- ES Module support
- HMAC SHA-256 hash generator to Hex Lower
Installation
npm install crypto-engine
## Usage
### AES-GCM Encrypt Payload
```js
import aesGcmEncryptBase64 from "crypto-engine/aesGcmEncrypt";
const encryptedBody = aesGcmEncryptBase64(
{ amount: 1000 },
AES_KEY_BASE64,
IV_STRING
);
### RSA-ENCRYPT Encrypt
import rsaEncrypt from "crypto-engine/rsaEncrypt";
const encryptedKey = rsaEncrypt(
AES_KEY_BASE64 or IV_STRING,
SERVER_PUBLIC_KEY_BASE64
);
### RSA-ENCRYPT Encrypt
import rsaDecrypt from "crypto-engine/rsaDecrypt";
const decryptedStr = rsaDecrypt(
inputBase64Str,
AES_KEY_BASE64,
IV_STRING
);
### HMAC SHA-256 hash generator Hex Lower
const hmacHexLower = hmacSha256HexLower (
signInput, mAesKey
)
