JSPM

huawei-modem-encryption

1.1.4
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 1
    • Score
      100M100P100Q27087F
    • License BSD

    Basic JavaScript BigNumber library for RSA encryption

    Package Exports

    • huawei-modem-encryption
    • huawei-modem-encryption/dist/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (huawei-modem-encryption) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    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" or 1 for OAEP padding, any other value (like "0", 0, etc.) for PKCS#1 v1.5 padding 🔒

    Note: The public key (n and e) 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

    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.