npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aleen42/jsbn

v1.3.1

Published

The jsbn library is a pure JavaScript implementation of arbitrary-precision integer arithmetic.

Downloads

4

Readme

BigIntegers and RSA in JavaScript

The jsbn library is a pure JavaScript implementation of arbitrary-precision integer arithmetic.

Demos

Source Code

The API for the jsbn library closely resembles that of the java.math.BigInteger class in Java.

For example:

x = new BigInteger("abcd1234", 16);
y = new BigInteger("beef", 16);
z = x.mod(y);
alert(z.toString(16));

will print b60c.

  • jsbn.js - basic BigInteger implementation, just enough for RSA encryption and not much more.
  • jsbn2.js - the rest of the library, including most public BigInteger methods.
  • rsa.js - implementation of RSA encryption, does not require jsbn2.js.
  • rsa2.js - rest of RSA algorithm, including decryption and keygen.
  • rng.js - rudimentary entropy collector and RNG interface, requires a PRNG backend to define prng_newstate().
  • prng4.js - ARC4-based PRNG backend for rng.js, very small.
  • base64.js - Base64 encoding and decoding routines.

Interoperability

The demo encrypts strings directly using PKCS#1 encryption-style padding (type 2), which is currently the only supported format. To show interoperability with a potential OpenSSL-based backend that decrypts strings, try the following on any system with the OpenSSL command line tool installed:

  1. Generate a new public/private keypair:

    $ openssl genrsa -out key.pem
    Generating RSA private key, 512 bit long modulus
    ..++++++++++++
    ..............++++++++++++
    e is 65537 (0x10001)
    $
  2. Extract the modulus from your key:

    $ openssl rsa -in key.pem -noout -modulus
    Modulus=DA3BB4C40E3C7E76F7DBDD8BF3DF0714CA39D3A0F7F9D7C2E4FEDF8C7B28C2875F7EB98950B22AE82D539C1ABC1AB550BA0B2D52E3EF7BDFB78A5E817D74BBDB
    $
  3. Go to the RSA Encryption demo and paste the modulus value into the "Modulus (hex)" field at the bottom.

  4. Make sure the value in the "Public exponent" field is "10001", or whatever value your public key uses.

  5. Type in a short string (e.g. testing) into the "Plaintext (string)" field and click on "encrypt". The result should appear in the "Ciphertext" fields.

  6. Copy the base64 version of the ciphertext and paste it as the input of the following command:

    $ openssl base64 -d | openssl rsautl -inkey key.pem -decrypt
    1JW24UMKntVhmmDilAYC1AjLxgiWHBzTzZsCVAejLjVri92abLHkSyLisVyAdYVr
    fiS7FchtI9vupe9JF/m3Kg==

    Hit ctrl-D or whatever your OS uses for end-of-file. Your original plaintext should appear:

    testing$

Performance

Since jsbn is pure JavaScript, its performance will depend on the hardware as well as the quality of the JavaScript execution environment, but will be considerably slower than native implementations in languages such as C/C++ or Java.

On a 1GHz Intel PC running Mozilla:

On similar hardware, running IE6:

Timing measurements, especially under IE, appear to have limited precision for faster operations.

History

Licensing

jsbn is released under a BSD license. See LICENSE for details.

Tom Wu