Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@harmony-js/crypto

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harmony-js/crypto - npm Package Compare versions

Comparing version 0.1.55 to 0.1.56

0

dist/address.d.ts

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

136

dist/errors.d.ts
/**
* ## About this package
# @harmony-js/crypto
This package provides a collection of apis related to address management, kestore, encoding, and encrypt/decrypt.
## Installation
```
npm install @harmony-js/crypto
```
## Usage
```javascript
* const {
* encode,
* decode,
* randomBytes,
* toBech32,
* fromBech32,
* HarmonyAddress,
* generatePrivateKey,
* getPubkeyFromPrivateKey,
* getAddressFromPublicKey,
* getAddressFromPrivateKey,
* encryptPhrase,
* decryptPhrase
* } = require('@harmony-js/crypto');
* const { isPrivateKey, isAddress, isPublicKey } = require('@harmony-js/utils');
```
Address apis
```javascript
const bytes = randomBytes(20);
const addr = new HarmonyAddress(bytes);
console.log(addr.checksum);
console.log(addr.bech32);
console.log(HarmonyAddress.isValidBech32(addr.bech32));
```
RLP apis
```javascript
const encoded = '0x89010101010101010101';
const decoded = '0x010101010101010101';
console.log(encode(decoded));
console.log(decode(encoded));
```
Keystore apis
```javascript
const prv = generatePrivateKey();
const pub = getPubkeyFromPrivateKey(prv);
const addr = getAddressFromPublicKey(pub);
const addrPrv = getAddressFromPrivateKey(prv);
console.log(isPrivateKey(prv));
console.log(isPublicKey(pub));
console.log(isAddress(addr));
console.log(isAddress(addrPrv));
```
Encrypt/decrypt apis
```javascript
* const { Wallet } = require('@harmony-js/account');
* const myPhrase = new Wallet().newMnemonic();
* console.log(myPhrase);
* const pwd = '1234';
* encryptPhrase(myPhrase, pwd).then((value) => {
* console.log(value);
* decryptPhrase(JSON.parse(value), pwd).then(value => {
* console.log(value);
* });
* });
```
*
* `@harmony-js/crypot` provides a series of functions to deal with keys
*
* ## How to use this package
*
* ### Create a Harmony Instance
* ```javascript
* const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils');
*
* const hmy = new Harmony(
* 'http://localhost:9500',
* {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*
* ### Some examples
*
* ```javascript
* // randomBytes
* const bytes = hmy.crypto.randomBytes(20);
* console.log(bytes)
*
* // encryptPhrase
* const myPhrase = hmy.wallet.newMnemonic();
* const pwd = '1234';
* hmy.crypto.encryptPhrase(myPhrase, pwd).then((value) => {
* console.log(value);
* })
*
* // decryptThePhrase
* hmy.crypto.encryptPhrase(myPhrase, pwd).then((keystore) => {
* hmy.crypto.decryptPhrase(JSON.parse(keystore), pwd).then((value) => {
* console.log(value);
* })
* })
*
* // generatePrivateKey
* const privateKey = hmy.crypto.generatePrivateKey();
* console.log(privateKey)
*
* // getPubkeyFromPrivateKey
* const publicKey = hmy.crypto.getPubkeyFromPrivateKey(privateKey);
* console.log(publicKey);
*
* // getAddressFromPrivateKey
* const address = hmy.crypto.getAddressFromPrivateKey(privateKey);
* console.log(address);
*
* // getAddressFromPublicKey
* const address = hmy.crypto.getAddressFromPublicKey(publicKey);
* console.log(address);
*
* // toChecksumAddress
* const checksumAddr = hmy.crypto.toChecksumAddress(address);
* console.log(checksumAddr);
* ```
*
* @packageDocumentation

@@ -65,0 +79,0 @@ * @module harmony-crypto

"use strict";
/**
* ## About this package
# @harmony-js/crypto
This package provides a collection of apis related to address management, kestore, encoding, and encrypt/decrypt.
## Installation
```
npm install @harmony-js/crypto
```
## Usage
```javascript
* const {
* encode,
* decode,
* randomBytes,
* toBech32,
* fromBech32,
* HarmonyAddress,
* generatePrivateKey,
* getPubkeyFromPrivateKey,
* getAddressFromPublicKey,
* getAddressFromPrivateKey,
* encryptPhrase,
* decryptPhrase
* } = require('@harmony-js/crypto');
* const { isPrivateKey, isAddress, isPublicKey } = require('@harmony-js/utils');
```
Address apis
```javascript
const bytes = randomBytes(20);
const addr = new HarmonyAddress(bytes);
console.log(addr.checksum);
console.log(addr.bech32);
console.log(HarmonyAddress.isValidBech32(addr.bech32));
```
RLP apis
```javascript
const encoded = '0x89010101010101010101';
const decoded = '0x010101010101010101';
console.log(encode(decoded));
console.log(decode(encoded));
```
Keystore apis
```javascript
const prv = generatePrivateKey();
const pub = getPubkeyFromPrivateKey(prv);
const addr = getAddressFromPublicKey(pub);
const addrPrv = getAddressFromPrivateKey(prv);
console.log(isPrivateKey(prv));
console.log(isPublicKey(pub));
console.log(isAddress(addr));
console.log(isAddress(addrPrv));
```
Encrypt/decrypt apis
```javascript
* const { Wallet } = require('@harmony-js/account');
* const myPhrase = new Wallet().newMnemonic();
* console.log(myPhrase);
* const pwd = '1234';
* encryptPhrase(myPhrase, pwd).then((value) => {
* console.log(value);
* decryptPhrase(JSON.parse(value), pwd).then(value => {
* console.log(value);
* });
* });
```
*
* `@harmony-js/crypot` provides a series of functions to deal with keys
*
* ## How to use this package
*
* ### Create a Harmony Instance
* ```javascript
* const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils');
*
* const hmy = new Harmony(
* 'http://localhost:9500',
* {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*
* ### Some examples
*
* ```javascript
* // randomBytes
* const bytes = hmy.crypto.randomBytes(20);
* console.log(bytes)
*
* // encryptPhrase
* const myPhrase = hmy.wallet.newMnemonic();
* const pwd = '1234';
* hmy.crypto.encryptPhrase(myPhrase, pwd).then((value) => {
* console.log(value);
* })
*
* // decryptThePhrase
* hmy.crypto.encryptPhrase(myPhrase, pwd).then((keystore) => {
* hmy.crypto.decryptPhrase(JSON.parse(keystore), pwd).then((value) => {
* console.log(value);
* })
* })
*
* // generatePrivateKey
* const privateKey = hmy.crypto.generatePrivateKey();
* console.log(privateKey)
*
* // getPubkeyFromPrivateKey
* const publicKey = hmy.crypto.getPubkeyFromPrivateKey(privateKey);
* console.log(publicKey);
*
* // getAddressFromPrivateKey
* const address = hmy.crypto.getAddressFromPrivateKey(privateKey);
* console.log(address);
*
* // getAddressFromPublicKey
* const address = hmy.crypto.getAddressFromPublicKey(publicKey);
* console.log(address);
*
* // toChecksumAddress
* const checksumAddr = hmy.crypto.toChecksumAddress(address);
* console.log(checksumAddr);
* ```
*
* @packageDocumentation

@@ -66,0 +80,0 @@ * @module harmony-crypto

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

@@ -0,0 +0,0 @@ /**

{
"name": "@harmony-js/crypto",
"version": "0.1.55",
"version": "0.1.56",
"description": "crypto libraries for harmony",

@@ -21,3 +21,3 @@ "main": "dist/index.js",

"dependencies": {
"@harmony-js/utils": "0.1.55",
"@harmony-js/utils": "0.1.56",
"aes-js": "^3.1.2",

@@ -34,3 +34,3 @@ "bip39": "^2.5.0",

},
"gitHead": "c49abc56916e6edf7aa959e38397ff280e47ec30"
"gitHead": "8f8e17fdaed394af1c28cd133d6018bf48915a81"
}
/**
* ## About this package
# @harmony-js/crypto
This package provides a collection of apis related to address management, kestore, encoding, and encrypt/decrypt.
## Installation
```
npm install @harmony-js/crypto
```
## Usage
```javascript
* const {
* encode,
* decode,
* randomBytes,
* toBech32,
* fromBech32,
* HarmonyAddress,
* generatePrivateKey,
* getPubkeyFromPrivateKey,
* getAddressFromPublicKey,
* getAddressFromPrivateKey,
* encryptPhrase,
* decryptPhrase
* } = require('@harmony-js/crypto');
* const { isPrivateKey, isAddress, isPublicKey } = require('@harmony-js/utils');
```
Address apis
```javascript
const bytes = randomBytes(20);
const addr = new HarmonyAddress(bytes);
console.log(addr.checksum);
console.log(addr.bech32);
console.log(HarmonyAddress.isValidBech32(addr.bech32));
```
RLP apis
```javascript
const encoded = '0x89010101010101010101';
const decoded = '0x010101010101010101';
console.log(encode(decoded));
console.log(decode(encoded));
```
Keystore apis
```javascript
const prv = generatePrivateKey();
const pub = getPubkeyFromPrivateKey(prv);
const addr = getAddressFromPublicKey(pub);
const addrPrv = getAddressFromPrivateKey(prv);
console.log(isPrivateKey(prv));
console.log(isPublicKey(pub));
console.log(isAddress(addr));
console.log(isAddress(addrPrv));
```
Encrypt/decrypt apis
```javascript
* const { Wallet } = require('@harmony-js/account');
* const myPhrase = new Wallet().newMnemonic();
* console.log(myPhrase);
* const pwd = '1234';
* encryptPhrase(myPhrase, pwd).then((value) => {
* console.log(value);
* decryptPhrase(JSON.parse(value), pwd).then(value => {
* console.log(value);
* });
* });
```
*
* `@harmony-js/crypot` provides a series of functions to deal with keys
*
* ## How to use this package
*
* ### Create a Harmony Instance
* ```javascript
* const { Harmony } = require('@harmony-js/core');
* const { ChainID, ChainType } = require('@harmony-js/utils');
*
* const hmy = new Harmony(
* 'http://localhost:9500',
* {
* chainType: ChainType.Harmony,
* chainId: ChainID.HmyLocal,
* },
* );
* ```
*
* ### Some examples
*
* ```javascript
* // randomBytes
* const bytes = hmy.crypto.randomBytes(20);
* console.log(bytes)
*
* // encryptPhrase
* const myPhrase = hmy.wallet.newMnemonic();
* const pwd = '1234';
* hmy.crypto.encryptPhrase(myPhrase, pwd).then((value) => {
* console.log(value);
* })
*
* // decryptThePhrase
* hmy.crypto.encryptPhrase(myPhrase, pwd).then((keystore) => {
* hmy.crypto.decryptPhrase(JSON.parse(keystore), pwd).then((value) => {
* console.log(value);
* })
* })
*
* // generatePrivateKey
* const privateKey = hmy.crypto.generatePrivateKey();
* console.log(privateKey)
*
* // getPubkeyFromPrivateKey
* const publicKey = hmy.crypto.getPubkeyFromPrivateKey(privateKey);
* console.log(publicKey);
*
* // getAddressFromPrivateKey
* const address = hmy.crypto.getAddressFromPrivateKey(privateKey);
* console.log(address);
*
* // getAddressFromPublicKey
* const address = hmy.crypto.getAddressFromPublicKey(publicKey);
* console.log(address);
*
* // toChecksumAddress
* const checksumAddr = hmy.crypto.toChecksumAddress(address);
* console.log(checksumAddr);
* ```
*
* @packageDocumentation

@@ -65,0 +79,0 @@ * @module harmony-crypto

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc