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

ethereum-rsa

v1.0.5

Published

Encrypt and Decrypt message using Ethereum keys.

Downloads

23

Readme

ethereum-rsa

npm License: MIT

Encrypt and Decrypt message using Ethereum keys.

How it works?

  • Let's say, Alice wants to send secured message to Bob. This is How it will work:
  1. Alice encrypt message using his privatekey and Bob's publickey.
  2. Alice sends encrypted message to Bob.
  3. Bob decrypt message using his privatekey and Alice publickey.
Benifits:
  • Only Bob can read the message
  • Bob can be sure that the message really comes from Alice

Installation

npm install ethereum-rsa --save

Initialization

const EthRSA = require('ethereum-rsa');

Retrive PublicKey from PrivateKey:

This function will return the uncompressed publicKey from privateKey.

let publicKey = EthRSA.publicKeyByPrivateKey("4a2e11580d318f86079775229a377194d3629bb8448dfbfb8352d0cc4fc3f008");

console.log(publicKey);

Output:

04de9432ee891cbc70ff41acbcb253d06317703e943de2f2cb7aaae71dfa91ba0d8c4ed05dc7a6b804134b9225a539699bedb222e73900ebeea3bbf4161045f007

Encryption of Message:

Encrypt the message using sender's private key and recipient public key.

Parameters:
  • message: Message in plain text.
  • senderPrivateKey: Private key of the sender.
  • recipientPublicKey: Public key of the recipient. Public key should be in uncompressed format & 04 attached at left.
API:
EthRSA.encryptMessage(message, senderPrivateKey, recipientPublicKey);
Example:
EthRSA.encryptMessage(
    "Hey There!",
    "4a2e11580d318f86079775229a377194d3629bb8448dfbfb8352d0cc4fc3f008",
    "044f93e10b7a052260c4686dbfca7ac09d5d830c01bfe544b92438f65ebf961d64acf9992fd70565920f303bca209f7a4a96f10510a2ed0922485b4758cc2b180a"
)
.then(console.log);
Output:
br+Tol1WJkejU+rvUCm7dGm2IeOLF/SiMOi3i3Ho3G4=

Decryption of Message:

Decrypt the message using sender's public key and recipient private key. Here public key should be in uncompressed format & with 04 attached left side.

Parameters:
  • cipherText: Encrypted message.
  • recipientPrivateKey: Private key of the recipient.
  • senderPublicKey: Public key of the sender. Public key should be in uncompressed format & 04 attached at left.
API:
EthRSA.decryptMessage(cipherText, recipientPrivateKey, senderPublicKey);
Example:
EthRSA.decryptMessage(
    "br+Tol1WJkejU+rvUCm7dGm2IeOLF/SiMOi3i3Ho3G4=",
    "e4a2d1f1568c1eb7ffacdbaea7607d9e768fd3d3d97ec5119ccf5d8bb6c0e613",
    "04de9432ee891cbc70ff41acbcb253d06317703e943de2f2cb7aaae71dfa91ba0d8c4ed05dc7a6b804134b9225a539699bedb222e73900ebeea3bbf4161045f007"
)
.then(console.log);
Output:
Hey There!

Running tests:

npm test

Contributing

  • Issues & Pull requests are welcome! Fork, branch, and submit PR.

Changelog

Licence

MIT