{"id":28462342,"url":"https://github.com/akhawaja/ecc-crypto-helper","last_synced_at":"2025-07-03T16:31:36.489Z","repository":{"id":56056957,"uuid":"163021311","full_name":"akhawaja/ecc-crypto-helper","owner":"akhawaja","description":"A Node.js ECDH and RSA helper library.","archived":false,"fork":false,"pushed_at":"2022-02-20T11:32:44.000Z","size":132,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-07T04:09:05.344Z","etag":null,"topics":["aes-gcm","ecc","elliptic-curve-diffie-hellman","encryption","hash","hkdf","hmac","jsonwebtoken","jws","jwt","ksuid","nodejs-modules","rsa","rsa-cryptography","rsa-signature"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akhawaja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-24T20:19:18.000Z","updated_at":"2023-01-26T08:14:45.000Z","dependencies_parsed_at":"2022-08-15T12:20:33.169Z","dependency_job_id":null,"html_url":"https://github.com/akhawaja/ecc-crypto-helper","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/akhawaja/ecc-crypto-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhawaja%2Fecc-crypto-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhawaja%2Fecc-crypto-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhawaja%2Fecc-crypto-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhawaja%2Fecc-crypto-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akhawaja","download_url":"https://codeload.github.com/akhawaja/ecc-crypto-helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhawaja%2Fecc-crypto-helper/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263360758,"owners_count":23454780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes-gcm","ecc","elliptic-curve-diffie-hellman","encryption","hash","hkdf","hmac","jsonwebtoken","jws","jwt","ksuid","nodejs-modules","rsa","rsa-cryptography","rsa-signature"],"created_at":"2025-06-07T04:09:05.365Z","updated_at":"2025-07-03T16:31:36.472Z","avatar_url":"https://github.com/akhawaja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elliptic Curve Cryptography Helper Library\n\n[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Coverage Status](https://coveralls.io/repos/github/akhawaja/ecc-crypto-helper/badge.svg?branch=master)](https://coveralls.io/github/akhawaja/ecc-crypto-helper?branch=master)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n**Discalaimer:** This library contains encryption software that is subject to \nthe U.S. Export Administration Regulations. You may not export, re-export, \ntransfer or download this code or any part of it in violation of any United \nStates law, directive or regulation. In particular this software may not be \nexported or re-exported in any form or on any media to Iran, North Sudan, \nSyria, Cuba, or North Korea, or to denied persons or entities mentioned on any \nUS maintained blocked list.\n\n## Introduction\nProvides basic functions to start using ECC in your next project. Please see\nthe `Features` section for a quick description of what is available. \n\n## Features\n\n- aescbc128: Encrypt and decrypt using AES-CBC-128 scheme.\n- aescbc192: Encrypt and decrypt using AES-CBC-192 scheme.\n- aescbc256: Encrypt and decrypt using AES-CBC-256 scheme.\n- aesgcm128: Encrypt and decrypt using AES-GCM-128 scheme.\n- aesgcm192: Encrypt and decrypt using AES-GCM-192 scheme.\n- aesgcm256: Encrypt and decrypt using AES-GCM-256 scheme.\n- base62: Base62 Encode/decode functions.\n- base64: Base64 URL encode/decode functions.\n- common: Random string, numbers, and UTC timestamp.\n- ecc256: ECC with P-256 functions. Also contains functions to sign and verify\n          the signatures, and convert PEM certificates to JWK.\n- ecc384: ECC with P-384 functions. Also contains functions to sign and verify\n          the signatures, and convert PEM certificates to JWK.\n- ecc521: ECC with P-521 functions. Also contains functions to sign and verify\n          the signatures, and convert PEM certificates to JWK.\n- hash: SHA-256, SHA-384, and SHA-512 functions.\n- hmac: Generate HMAC.\n- hkdf: Key contraction and expansion algorithm to derive additional bytes.\n- jwt: Generate and verify JSON Web Tokens. The JWTs support ES384, ES512, \n       HS384, and HS512 algorithms.\n- ksuid: Generate and parse [KSUID](https://github.com/segmentio/ksuid) \n         identifiers. You can use this instead of a UUID.\n- password: Password hash and match functions. Uses Scrypt + HKDF for password \n            hashing.\n- rsa: Generate key pairs, perform public key encryption and private key \n       decryption, sign and verify using private and public keys respectively.\n       Convert RSA keys between PEM and JWK.\n\n## Example Usage\n\n1. Install the library.\n\n```\n$\u003e yarn add ecc-crypto-helper\n```\n\n2. Just import the file in your NodeJS project and start using it.\n\n```javascript\n// Import individual libraries\nvar common = require(\"ecc-crypto-helper/common\");\ncommon.random().then(function (result) {\n    console.log(result.toString(\"hex\"))\n});\n```\n\n**OR**\n\n```javascript\nvar eccHelper = require(\"ecc-crypto-helper\")\n\n// Generate a random value\nvar random = await eccHelper.common.random();\n\n// Generate a random number between 1 and 100\nvar randomNumber = await eccHelper.common.randomNumber(1, 100);\n\n// Base64 URL encode a string\nvar encoded = await eccHelper.base64.urlEncode(\"Hello world\");\n\n// Hash a password before storing it in your database\nvar plainPassword = \"I am a super password\";\nvar hashedPassword = (await eccHelper.password.hash(plainPassword)).toString(\"hex\");\n\n// Did the user supply the correct password?\nvar passwordMatch = await eccHelper.password.match(plainPassword, hashedPassword);\n\nif (passwordMatch) {\n    // Let the user in to the application\n} else {\n    // Password was not correct\n}\n\n// Encrypt a string using AES-GCM-256\nvar password = \"This is a secret\";\nvar cipherText = await eccHelper.aesGcm256.encrypt(\"This is a message\", password);\n\n// Decrypt the previously encrypted string\nvar plainText = await eccHelper.aesGcm256.decrypt(cipherText, password);\n\n// Derive a random set of characters using HKDF\nvar initialKeyMaterial = \"This is a secret\";\nvar size = 64;\nvar bytesBuffer = await eccHelper.hkdf.derive(initialKeyMaterial, size);\n\n// Generate a JSON Web Token using HS512\nvar sharedSecret = \"This is a secret\";\nvar claims = {\"username\":\"bob\"};\nvar webToken = await eccHelper.jwt.hs512.create(sharedSecret, claims);\n\n// Decode the JSON Web Token\nvar decodedToken = await eccHelper.jwt.decode(webToken);\n\n// Generate a RSA key pair\nvar rsaKeyPair = await eccHelper.rsa.generateKeyPair(2048) // 1024, 2048, or 4096\nvar jwkPrivateKey = await eccHelper.rsa.convertPemToJwk(rsaKeyPair.privateKey)\nvar jwkPublicKey = await eccHelper.rsa.convertPemToJwk(rsaKeyPair.publicKey)\nvar rsaPrivateKey = await eccHelper.rsa.convertJwkToPem(jwkPrivateKey)\nvar rsaPublicKey = await eccHelper.rsa.convertJwkToPem(jwkPublicKey)\n\n// Generate an ECDH key pair\nvar keyPair = await eccHelper.ecc521.generatePemKeyPair();\n\n// Generate a JSON Web Token using ES512\nwebToken = await eccHelper.jwt.es512.create(keyPair.privateKey, claims);\n\n// Create and parse KSUID\nvar ksuid = await eccHelper.ksuid.create();\nvar parsed = await eccHelper.ksuid.parse(ksuid);\n\n// Generate a shared secret\nvar sharedSecret = await eccHelper.sharedSecretGenerator.generateSharedSecret(32) // 256-bit key\nvar sharedSecretToJSONWebKey = await eccHelper.sharedSecretGenerator.convertSharedSecretToJwk(sharedSecret)\nvar sharedSecretAsJSONWebKey = await eccHelper.sharedSecretGenerator.generateSharedSecretAsJwk(32) // 256-bit key\n```\n\nSee the `test/spec.js` file for more examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhawaja%2Fecc-crypto-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakhawaja%2Fecc-crypto-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhawaja%2Fecc-crypto-helper/lists"}