# @huobiwallet-js/crypto

> crypto libraries for huobiwallet

Latest version **0.0.12** (published 2020-12-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @huobiwallet-js/crypto
pnpm add @huobiwallet-js/crypto
yarn add @huobiwallet-js/crypto
bun add @huobiwallet-js/crypto
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: insecure dependencies; abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2020-12-29 |
| First published | 2020-12-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 11 |
| Unpacked size | 1 MB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | huobichain |

## Links

- npm: https://www.npmjs.com/package/@huobiwallet-js/crypto
- npm.io page: https://npm.io/package/@huobiwallet-js/crypto

## Dependencies (11)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [bip39](https://npm.io/package/bip39.md) ^2.5.0
- [bn.js](https://npm.io/package/bn.js.md) ^4.11.8
- [hdkey](https://npm.io/package/hdkey.md) ^1.1.1
- [aes-js](https://npm.io/package/aes-js.md) ^3.1.2
- [pbkdf2](https://npm.io/package/pbkdf2.md) ^3.0.17
- [js-sha3](https://npm.io/package/js-sha3.md) ^0.8.0
- [elliptic](https://npm.io/package/elliptic.md) ^6.4.1
- [hmac-drbg](https://npm.io/package/hmac-drbg.md) ^1.0.1
- [scrypt-shim](https://npm.io/package/scrypt-shim.md) github:web3-js/scrypt-shim
- [@huobiwallet-js/utils](https://npm.io/package/@huobiwallet-js/utils.md) ^0.0.12

## Recent versions

- 0.0.12 (latest) — 2020-12-29

## README

# @huobiwallet-js/crypto

This package provides a collection of apis related to address management, kestore, encoding, and encrypt/decrypt.

## Installation

```
npm install @huobiwallet-js/crypto
```

## Usage

```javascript
const {
  encode,
  decode,
  randomBytes,
  toBech32,
  fromBech32,
  HuobiwalletAddress,
  generatePrivateKey,
  getPubkeyFromPrivateKey,
  getAddressFromPublicKey,
  getAddressFromPrivateKey,
  encryptPhrase,
  decryptPhrase
} = require('@huobiwallet-js/crypto');
const { isPrivateKey, isAddress, isPublicKey } = require('@huobiwallet-js/utils');
```

Address apis
```javascript
const bytes = randomBytes(20);
const addr = new HuobiwalletAddress(bytes);

console.log(addr.checksum);
console.log(addr.bech32);

console.log(HuobiwalletAddress.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('@huobiwallet-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);
  });
});
```

---
_Source: https://npm.io/package/@huobiwallet-js/crypto · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
