How to use the jsencrypt.default function in jsencrypt

To help you get started, we’ve selected a few jsencrypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lsqswl / rsaencrypt / lib / index.js View on Github external
function encryptPublicLong(text, publicKey) {
    var rsa = new jsencrypt_1["default"]();
    rsa.setPublicKey(publicKey);
    var key = rsa.getKey();
    var ct = "";
    // RSA每次加密117bytes,需要辅助方法判断字符串截取位置
    // 1.获取字符串截取点
    var bytes = new Array();
    bytes.push(0);
    var byteNo = 0;
    var len = text.length;
    var c;
    var temp = 0;
    for (var i = 0; i < len; i++) {
        c = text.charCodeAt(i);
        if (c >= 0x010000 && c <= 0x10FFFF) { // 特殊字符,如Ř,Ţ
            byteNo += 4;
        }
github lsqswl / rsaencrypt / lib / index.js View on Github external
function decryptPrivateLong(text, privateKey) {
    var rsa = new jsencrypt_1["default"]();
    rsa.setPrivateKey(privateKey);
    var key = rsa.getKey();
    text = b64tohex(text);
    var maxLength = ((key.n.bitLength() + 7) >> 3);
    try {
        if (text.length > maxLength) {
            var ct1_1 = "";
            var lt = text.match(/.{1,256}/g);
            if (lt) {
                lt.forEach(function (entry) {
                    var t1 = key.decrypt(entry);
                    ct1_1 += t1;
                });
            }
            return ct1_1;
        }

jsencrypt

A Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation.

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis