Secure, Laravel-compatible encryption and decryption using AES-256-CBC for Node.js.
This package is designed to match the encryption scheme used by the DevPayr platform, enabling safe communication between Node.js clients and the DevPayr server.
- 🔐 AES-256-CBC encryption with random IV
- 🔑 Accepts any key and normalizes to 32-byte (via SHA-256)
- 📦 Base64-encoded output compatible with Laravel
encrypt_secure()/decrypt_secure() - ⚡ Lightweight and dependency-free (uses Node's built-in
crypto)
npm install @xultech/devpayr-cryptoconst { encryptSecure } = require('@xultech/devpayr-crypto');
const key = 'sk_devpayr_test123';
const plaintext = 'Hello, DevPayr!';
const encrypted = encryptSecure(plaintext, key);
console.log(encrypted); // Outputs: base64(iv::cipherText)const { decryptSecure } = require('@xultech/devpayr-crypto');
const encrypted = '...'; // base64 string from `encryptSecure`
const key = 'sk_devpayr_test123';
const decrypted = decryptSecure(encrypted, key);
console.log(decrypted); // Outputs: Hello, DevPayr!-
Uses AES-256-CBC with a 16-byte random IV.
-
Keys are normalized to 32 bytes using SHA-256 (to meet AES-256 requirements).
-
Final format is: base64(iv::cipherText) — fully compatible with Laravel backend.
const { encryptSecure, decryptSecure } = require('@xultech/devpayr-crypto');
const key = 'sk_devpayr_test123';
const original = 'API key: ABC123';
const encrypted = encryptSecure(original, key);
console.log('Encrypted:', encrypted);
const decrypted = decryptSecure(encrypted, key);
console.log('Decrypted:', decrypted);MIT © DevPayr