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

kare_encryption

v2.5.2

Published

cryptographic functions for secure communication

Downloads

17

Readme

KARE ENCRYPTION

npm package - https://www.npmjs.com/package/kare_encryption

npm GitHub license GitHub issues

Install

$ npm install kare_encryption

Usage

Initialize

const kare_enc = new (require('kare_encryption'));

Hash

hashMessage(message) - Returns SHA256 Hash value, given a message as the input parameter.

Example :
msgHash = kare_enc.hashMessage("abcd"); //generates SHA256 hash of "abcd"

Generate RSA Key Pair

generateRSAKeyPair([keyLength]) - Returns a private public key pair in the form of pkcs8-pem in a json object structured as {publicKey: publicKey, privateKey: privateKey}. keyLength is an optional parameter defaulted to 2048.

Example :
keyPair = kare_enc.generateRSAKeyPair(3072); //generates a RSA key pair of bit-length 3072
keyPair = kare_enc.generateRSAKeyPair(); //generates a RSA key pair of bit-length 2048 - default key length

Encrypt

publicKeyEncrypt(message, publicKey) - Returns the encrypted value in base64 format, given a message and the public key in pkcs8-pem format.

Example :
const publicKey = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3TgRFRR+YaLwu6Re7901\nNeGxP6q0+Kj5SDStNjkH4KGnr/pz+QX+fI6Wvy5WONvAhwV+jcQEux6yqGUB9R6v\n2j10tizAFSD8LJD7TwfYVVXMHXVQlcF69Ab7n8TNmSzxI76IcSiOl3eJUPyhj+fz\nGvJv/QVNxmblvLcaoqqDpPZJFZBNIdG9MWxjbgQ6/Vr4kLEiptMQoNo2eMUjJ/Sz\ngrVD/FdDD9vkdhHyemkUNqZI3E0zBbyS4u/P3DGakAyteMIRXTe1j4+M6EpQKRAp\n22Ke7sg5lUbGuHI0OBstCnTjPK4NLS9NeGlgezBUVt+288PFnfgWEZe5FE7MoyiG\nawIDAQAB\n-----END PUBLIC KEY-----";
const encryptedMessage = kare_enc.publicKeyEncrypt("abcdef", publicKey); //generates the encrypted value of "abcdef"

Decrypt

privateKeyDecrypt(encryptedMessage, privateKey) - Returns the derypted value in utf8 encoded string format, given the encrypted value in base64 format and the private key in pkcs8-pem format.

Example :
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDdOBEVFH5hovC7\npF7v3TU14bE/qrT4qPlINK02OQfgoaev+nP5Bf58jpa/LlY428CHBX6NxAS7HrKo\nZQH1Hq/aPXS2LMAVIPwskPtPB9hVVcwddVCVwXr0BvufxM2ZLPEjvohxKI6Xd4lQ\n/KGP5/Ma8m/9BU3GZuW8txqiqoOk9kkVkE0h0b0xbGNuBDr9WviQsSKm0xCg2jZ4\nxSMn9LOCtUP8V0MP2+R2EfJ6aRQ2pkjcTTMFvJLi78/cMZqQDK14whFdN7WPj4zo\nSlApECnbYp7uyDmVRsa4cjQ4Gy0KdOM8rg0tL014aWB7MFRW37bzw8Wd+BYRl7kU\nTsyjKIZrAgMBAAECggEBAIwP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uN6rN+Hrdn1VWh/0\nBZSjYxpThJ1UkWZzKYneVBtJN08S4X5HR0xBJjLHVg6DYH88uS8z9j68TUOyI1EX\nd0R8K+7klJ4gtlvjqac2zvZjJ2m67udQcwGBlAmam78dlPJP7T2PHV+BmMZierck\nnA76Qr/jKeph7o3RWM1M+/2HPA==\n-----END PRIVATE KEY-----";
const message = kare_enc.privateKeyDecrypt(encryptedMessage, privateKey); //generates the decrypted value of encryptedMessage

Sign

signMessage(message, privateKey) - Returns the signed value in base64 format given a message in utf8 encoding and private key in pkcs8-pem format.

Example :
sign = kare_enc.signMessage("abcdef", privateKey); //generates the sign  value of "abcdef"

Verify

verifyMessage(message, sign, publicKey) - Returns the results of verification true or false given a message in utf8 encoding, signature in base64 format and public key in pkcs8-pem format.

Example :
verification = kare_enc.verifyMessage("abcdef", sign, publicKey); //return the result of "abcdef" and sign