{"_id":"@aleen42/jsbn","name":"@aleen42/jsbn","dist-tags":{"latest":"1.3.1"},"versions":{"1.3.1":{"name":"@aleen42/jsbn","version":"1.3.1","description":"The jsbn library is a pure JavaScript implementation of arbitrary-precision integer arithmetic.","main":"jsbn.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/yeesunday/jsbn.git"},"author":{"name":"yeesunday"},"license":"ISC","bugs":{"url":"https://github.com/yeesunday/jsbn/issues"},"homepage":"https://github.com/yeesunday/jsbn#readme","_id":"@aleen42/jsbn@1.3.1","gitHead":"ac4dacb3cfbd66ea29fd59d50dbdf360356e287e","_nodeVersion":"22.2.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-OGdyNJga9LJxL9DtsN33LE6BIXgUEUmElcZAMYTnKbVJTOfUZ/nBmQZUsAQbXsRFdjU+i313aTojEbwOgOuK1w==","shasum":"c1e83a0e8c5fee58da8bd07f64eedec439e59d79","tarball":"https://registry.npmjs.org/@aleen42/jsbn/-/jsbn-1.3.1.tgz","fileCount":16,"unpackedSize":89095,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFqdZZJXnMQ2f0uut8TG6Y7rLtgCjbzfsAAPZIBXsITCAiAx11fmNmPe8ztZC9jR17U4mo1nY6jxwpEasyUYyjbsBw=="}]},"_npmUser":{"name":"aleen42","email":"aleen42@vip.qq.com"},"directories":{},"maintainers":[{"name":"aleen42","email":"aleen42@vip.qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsbn_1.3.1_1721470431860_0.9089020634852849"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-20T10:13:51.778Z","1.3.1":"2024-07-20T10:13:52.066Z","modified":"2024-07-20T10:13:52.316Z"},"maintainers":[{"name":"aleen42","email":"aleen42@vip.qq.com"}],"description":"The jsbn library is a pure JavaScript implementation of arbitrary-precision integer arithmetic.","homepage":"https://github.com/yeesunday/jsbn#readme","repository":{"type":"git","url":"git+https://github.com/yeesunday/jsbn.git"},"author":{"name":"yeesunday"},"bugs":{"url":"https://github.com/yeesunday/jsbn/issues"},"license":"ISC","readme":"BigIntegers and RSA in JavaScript\n=================================\n\nThe `jsbn` library is a pure JavaScript implementation of arbitrary-precision\ninteger arithmetic.\n\nDemos\n-----\n\n * [RSA Encryption Demo](rsa.html) - simple RSA encryption of a string with a\n   public key\n * [RSA Cryptography Demo](rsa2.html) - more complete demo of RSA encryption,\n   decryption, and key generation\n\nSource Code\n-----------\n\nThe API for the `jsbn` library closely resembles that of the\n[`java.math.BigInteger`](http://java.sun.com/j2se/1.3/docs/api/java/math/BigInteger.html) class in Java.\n\nFor example:\n\n    x = new BigInteger(\"abcd1234\", 16);\n    y = new BigInteger(\"beef\", 16);\n    z = x.mod(y);\n    alert(z.toString(16));\n\nwill print `b60c`.\n\n * [`jsbn.js`](jsbn.js) - basic BigInteger implementation, just enough for RSA encryption and not much more.\n * [`jsbn2.js`](jsbn2.js) - the rest of the library, including most public `BigInteger` methods.\n * [`rsa.js`](rsa.js) - implementation of RSA encryption, does not require `jsbn2.js`.\n * [`rsa2.js`](rsa2.js) - rest of RSA algorithm, including decryption and keygen.\n * [`rng.js`](rng.js) - rudimentary entropy collector and RNG interface, requires a PRNG backend to define `prng_newstate()`.\n * [`prng4.js`](prng4.js) - ARC4-based PRNG backend for `rng.js`, very small.\n * [`base64.js`](base64.js) - Base64 encoding and decoding routines.\n\nInteroperability\n----------------\n\nThe demo encrypts strings directly using PKCS#1 encryption-style\npadding (type 2), which is currently the only supported format.\nTo show interoperability with a potential OpenSSL-based backend\nthat decrypts strings, try the following on any system with the\nOpenSSL command line tool installed:\n\n 1. Generate a new public/private keypair:\n\n        $ openssl genrsa -out key.pem\n        Generating RSA private key, 512 bit long modulus\n        ..++++++++++++\n        ..............++++++++++++\n        e is 65537 (0x10001)\n        $\n\n 2. Extract the modulus from your key:\n\n        $ openssl rsa -in key.pem -noout -modulus\n        Modulus=DA3BB4C40E3C7E76F7DBDD8BF3DF0714CA39D3A0F7F9D7C2E4FEDF8C7B28C2875F7EB98950B22AE82D539C1ABC1AB550BA0B2D52E3EF7BDFB78A5E817D74BBDB\n        $\n\n 3. Go to the [RSA Encryption demo](rsa.html) and paste the modulus value into the\n    \"Modulus (hex)\" field at the bottom.\n 4. Make sure the value in the \"Public exponent\" field is \"10001\", or whatever\n    value your public key uses.\n 5. Type in a short string (e.g. `testing`) into the \"Plaintext (string)\" field\n    and click on \"encrypt\".  The result should appear in the \"Ciphertext\"\n    fields.\n 6. Copy the base64 version of the ciphertext and paste it as the input of\n    the following command:\n\n        $ openssl base64 -d | openssl rsautl -inkey key.pem -decrypt\n        1JW24UMKntVhmmDilAYC1AjLxgiWHBzTzZsCVAejLjVri92abLHkSyLisVyAdYVr\n        fiS7FchtI9vupe9JF/m3Kg==\n\n    Hit ctrl-D or whatever your OS uses for end-of-file.\n    Your original plaintext should appear:\n\n        testing$\n\nPerformance\n-----------\n\nSince `jsbn` is pure JavaScript, its performance will depend on the hardware as\nwell as the quality of the JavaScript execution environment, but will be\nconsiderably slower than native implementations in languages such as C/C++ or\nJava.\n\nOn a 1GHz Intel PC running Mozilla:\n\n<table cellspacing=5>\n<tr><th align=left>Key type</th><th align=center>Encryption time</th><th align=center>Decryption time</th></tr>\n<tr><td align=left>RSA 512-bit (e=3)</td><td align=center>23ms</td><td align=center>1.0s</td></tr>\n<tr><td align=left>RSA 512-bit (e=F4)</td><td align=center>86ms</td><td align=center>1.0s</td></tr>\n<tr><td align=left>RSA 1024-bit (e=3)</td><td align=center>56ms</td><td align=center>6.0s</td></tr>\n<tr><td align=left>RSA 1024-bit (e=F4)</td><td align=center>310ms</td><td align=center>6.0s</td></tr>\n</table>\n\nOn similar hardware, running IE6:\n\n<table cellspacing=5>\n<tr><th align=left>Key type</th><th align=center>Encryption time</th><th align=center>Decryption time</th></tr>\n<tr><td align=left>RSA 512-bit (e=3)</td><td align=center>50ms</td><td align=center>0.7s</td></tr>\n<tr><td align=left>RSA 512-bit (e=F4)</td><td align=center>60ms</td><td align=center>0.7s</td></tr>\n<tr><td align=left>RSA 1024-bit (e=3)</td><td align=center>60ms</td><td align=center>4.3s</td></tr>\n<tr><td align=left>RSA 1024-bit (e=F4)</td><td align=center>220ms</td><td align=center>4.3s</td></tr>\n</table>\n\nTiming measurements, especially under IE, appear to have limited\nprecision for faster operations.\n\nHistory\n-------\n\n<dl>\n<dt><b>Version 1.3 (7/3/2012):</b></dt>\n<dd>Fixed bug when comparing negative integers of different word lengths.\n<dt><b>Version 1.2 (3/29/2011):</b></dt>\n<dd>Added <code>square</code> method to improve ECC performance.\n<dd>Use randomized bases in <code>isProbablePrime</code>\n<dt><b>Version 1.1 (9/15/2009):</b></dt>\n<dd>Added support for utf-8 encoding of non-ASCII characters\nwhen PKCS1 encoding and decoding JavaScript strings.\n<dd>Fixed bug when creating a new BigInteger(\"0\") in a non power-of-2 radix.\n</dl>\n\nLicensing\n---------\n\n`jsbn` is released under a BSD license.\nSee [`LICENSE`](LICENSE) for details.\n\n[Tom Wu](mailto:tjw@cs.stanford.edu)\n","readmeFilename":"README.md"}