huawei-modem-encryption
Version:
Basic JavaScript BigNumber library for RSA encryption
64 lines (42 loc) • 2.26 kB
Markdown
for RSA encryption used by Huawei modems. This library provides functionality to encrypt passwords and other sensitive data using **RSA PKCS
```sh
npm install huawei-modem-encryption
```
```javascript
import { doRSAEncrypt } from 'huawei-modem-encryption';
// Example usage:
const encryptedString = doRSAEncrypt(
"password", // 🔑 String to encrypt
publicKeyN, // 🔐 RSA public key modulus (n)
publicKeyE, // 🔐 RSA public key exponent (e)
0 // 🔓 Login status is 0 (logged in)
);
```
- **`string`**: The data to be encrypted (e.g., password) 🔑
- **`publicKeyN`**: The RSA public key modulus (n) 🔐
- **`publicKeyE`**: The RSA public key exponent (e) 🔐
- **`loginStatus`**: `0` for logged in 🔓
> **Note**: The public key (`n` and `e`) should be obtained from your Huawei modem's API or documentation.
## ✨ Features
- 🔐 **RSA encryption** with PKCS#1 v1.5 and OAEP padding support
- 📜 **Base64 encoding** of encrypted data
- 🎲 **Built-in secure random number generation**
- 🛡️ **SHA-1 hashing** for OAEP padding
## 📜 License
BSD License
This package contains code derived from Tom Wu's RSA implementation.
Copyright (c) 2005 Tom Wu
All Rights Reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
## 👨💻 Authors
Original Author: Tom Wu
Republished by: Doni Setiawan
📧 doni.setiawan@salt.co.id
*This is a republished version of a Huawei modem encryption implementation.*
A **JavaScript library**