huawei-modem-encryption
v1.1.5
Published
Basic JavaScript BigNumber library for RSA encryption
Maintainers
Readme
🔒 Huawei Modem Encryption
A JavaScript library for RSA encryption used by Huawei modems. This library provides functionality to encrypt passwords and other sensitive data using RSA PKCS#1 with both padding types.
📦 Installation
npm install huawei-modem-encryption🚀 Usage
import { doRSAEncrypt } from 'huawei-modem-encryption';
// Example usage with OAEP padding:
const encryptedString = doRSAEncrypt(
"password", // 🔑 String to encrypt
publicKeyN, // 🔐 RSA public key modulus (n)
publicKeyE, // 🔐 RSA public key exponent (e)
"1" // 🔒 RSA padding type: "1" or 1 for OAEP
);
// Example usage with PKCS#1 v1.5 padding:
const encryptedString2 = doRSAEncrypt(
"password", // 🔑 String to encrypt
publicKeyN, // 🔐 RSA public key modulus (n)
publicKeyE, // 🔐 RSA public key exponent (e)
"0" // 🔒 RSA padding type: "0", 0, or any other value for PKCS#1 v1.5
);📝 Parameters
encstring: The data to be encrypted (e.g., password) 🔑encpubkeyn: The RSA public key modulus (n) 🔐encpubkeye: The RSA public key exponent (e) 🔐rsaPaddingType: RSA padding type -"1"or1for OAEP padding, any other value (like"0",0, etc.) for PKCS#1 v1.5 padding 🔒
Note: The public key (
nande) should be obtained from your Huawei modem's API or documentation.
✨ Features
- 🔐 RSA encryption with dual padding support:
- PKCS#1 v1.5 padding (default) - Compatible with most Huawei modems
- OAEP padding - Enhanced security with SHA-1 hashing
- 📜 Base64 encoding of input data before encryption
- 🎲 Built-in secure random number generation
- 🛡️ SHA-1 hashing for OAEP padding
- 📦 Chunked encryption - Handles large data by splitting into appropriate chunks based on padding type
📜 License
Licensed under BSD-3-Clause. See the full license text in LICENSE.
This package contains code derived from Tom Wu's RSA implementation. Copyright (c) 2005 Tom Wu.
👨💻 Authors
Original Author: Tom Wu
Republished by: Doni Setiawan
This is a republished version of a Huawei modem encryption implementation.
