@darkwolf/base58
Advanced tools
Comparing version 21.13.6 to 100.0.0
{ | ||
"name": "@darkwolf/base58", | ||
"version": "21.13.6", | ||
"version": "100.0.0", | ||
"description": "Base58", | ||
"type": "module", | ||
"main": "./lib/index.cjs", | ||
"exports": { | ||
".": "./src/index.mjs", | ||
"./errors": "./src/errors/index.mjs", | ||
"./errors/": "./src/errors/", | ||
"./errors/Base58Error": "./src/errors/Base58Error.mjs", | ||
"./errors/InvalidAlphabetError": "./src/errors/InvalidAlphabetError.mjs", | ||
"./Base58Error": "./src/errors/Base58Error.mjs", | ||
"./InvalidAlphabetError": "./src/errors/InvalidAlphabetError.mjs", | ||
"./constants": "./src/constants/index.mjs", | ||
"./constants/": "./src/constants/", | ||
"./constants/Alphabet": "./src/constants/Alphabet.mjs", | ||
"./Alphabet": "./src/constants/Alphabet.mjs", | ||
"./package.json": "./package.json" | ||
"import": "./lib/index.mjs", | ||
"require": "./lib/index.cjs" | ||
}, | ||
"engines": { | ||
"node": ">=12.18.3" | ||
"node": ">=12" | ||
}, | ||
@@ -28,6 +19,5 @@ "scripts": { | ||
"type": "git", | ||
"url": "git+https://github.com/Darkwolf/base58.git" | ||
"url": "git+https://github.com/Darkwolf/node-base58.git" | ||
}, | ||
"keywords": [ | ||
"darkwolf", | ||
"base58", | ||
@@ -40,5 +30,8 @@ "encoder", | ||
"bugs": { | ||
"url": "https://github.com/Darkwolf/base58/issues" | ||
"url": "https://github.com/Darkwolf/node-base58/issues" | ||
}, | ||
"homepage": "https://github.com/Darkwolf/base58#readme" | ||
"homepage": "https://github.com/Darkwolf/node-base58#readme", | ||
"dependencies": { | ||
"@darkwolf/primordials": "^1.1.9" | ||
} | ||
} |
# Base58 | ||
## Install | ||
`npm i --save @darkwolf/base58` | ||
## Using | ||
#### ⚠️ Requires Node.js v12.x LTS or higher to use! | ||
## Usage | ||
```javascript | ||
import Base58, { Alphabet } from '@darkwolf/base58' | ||
// ECMAScript | ||
import Base58 from '@darkwolf/base58' | ||
// CommonJS | ||
const Base58 = require('@darkwolf/base58') | ||
const encoded = Base58.encode('Ave, Darkwolf!') // HDmiyDYm3PDiZ4kmjkb | ||
Base58.decode(encoded) // 'Ave, Darkwolf!' | ||
const encodedInteger = Base58.encodeInteger(10000) // eyH | ||
Base58.decodeInteger(encodedInteger) // 10000 | ||
// Custom alphabet | ||
const btc = new Base58(Alphabet.BITCOIN) | ||
const encodedBtc = btc.encode('Ave, Darkwolf!') // R4qoy4gqDX4ohE7qp7i | ||
btc.decode(encodedBtc) // 'Ave, Darkwolf!' | ||
const encodedBtcInteger = btc.encodeInteger(10000) // 3yR | ||
btc.decodeInteger(encodedBtcInteger) // 10000 | ||
// Number Encoding | ||
const integer = Number.MAX_SAFE_INTEGER // => 9007199254740991 | ||
const encodedInt = Base58.encodeInt(integer) // => '2DLNrMSKug' | ||
const decodedInt = Base58.decodeInt(encodedInt) // => 9007199254740991 | ||
const negativeInteger = -integer // => -9007199254740991 | ||
const encodedNegativeInt = Base58.encodeInt(negativeInteger) // => '-2DLNrMSKug' | ||
const decodedNegativeInt = Base58.decodeInt(encodedNegativeInt) // => -9007199254740991 | ||
// BigInt Encoding | ||
const bigInt = BigInt(Number.MAX_VALUE) // => 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n | ||
const encodedBigInt = Base58.encodeBigInt(bigInt) // => 'TCQK6EStJJFRT5mocK94qjPbLcHsyGYEcv2bSnJG6E4DJExMT7t2evaWif2UdjBzMW2mc8DBzMvPnog84qpBGuKfTRUqBxcPpi1KuA3qB9ee7hHwMoDJmZz26J8RTFPhYQvegn4dffqS5Ju2JF5W5Em7uS78WE8usBwLCpUYKpGGAmV' | ||
const decodedBigInt = Base58.decodeBigInt(encodedBigInt) // => -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n | ||
const negativeBigInt = -bigInt // => -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n | ||
const encodedNegativeBigInt = Base58.encodeBigInt(negativeBigInt) // => '-TCQK6EStJJFRT5mocK94qjPbLcHsyGYEcv2bSnJG6E4DJExMT7t2evaWif2UdjBzMW2mc8DBzMvPnog84qpBGuKfTRUqBxcPpi1KuA3qB9ee7hHwMoDJmZz26J8RTFPhYQvegn4dffqS5Ju2JF5W5Em7uS78WE8usBwLCpUYKpGGAmV' | ||
const decodedNegativeBigInt = Base58.decodeBigInt(encodedNegativeBigInt) // => -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n | ||
// Text Encoding | ||
const text = 'Ave, Darkwolf!' | ||
const encodedText = Base58.encodeText(text) // => 'R4qoy4gqDX4ohE7qp7i' | ||
const decodedText = Base58.decodeText(encodedText) // => 'Ave, Darkwolf!' | ||
const emojis = '🐺🐺🐺' | ||
const encodedEmojis = Base58.encodeText(emojis) // => '5YN9We97aSqpNeq13' | ||
const decodedEmojis = Base58.decodeText(encodedEmojis) // => '🐺🐺🐺' | ||
// Buffer Encoding | ||
const buffer = Uint8Array.of(0x00, 0x02, 0x04, 0x08, 0x0f, 0x1f, 0x3f, 0x7f, 0xff) // => <Uint8Array 00 02 04 08 0f 1f 3f 7f ff> | ||
const encodedBuffer = Base58.encode(buffer) // => <Uint8Array 31 4c 5a 43 78 72 75 44 44 4c 32> | ||
const decodedBuffer = Base58.decode(encodedBuffer) // => <Uint8Array 00 02 04 08 0f 1f 3f 7f ff> | ||
// Custom Alphabet | ||
const dw58 = new Base58('AveDarkwo1f23456789BCEFGHJKLMNPQRSTUVWXYZbcdghijmnpqstuxyz') | ||
const encInt = dw58.encodeInt(integer) // => 'v3BEnCJ9sY' | ||
const decInt = dw58.decodeInt(encInt) // => 9007199254740991 | ||
const encNegativeInt = dw58.encodeInt(negativeInteger) // => '-v3BEnCJ9sY' | ||
const decNegativeInt = dw58.decodeInt(encNegativeInt) // => -9007199254740991 | ||
const encBigInt = dw58.encodeBigInt(bigInt) // 'K2G9r4Jq885HKagiU9oDmcFTBU7py6Q4UtvTJh86r4D384xCKkqvWtSNbXvLVcfzCNvgUw3fzCtFhiYwDmjf6s9XKHLmfxUFjbA9s1emfoWWkZ7uCi38gRzvr8wHK5FZQGtWYhDVXXmJa8sv85aNa4gksJkwN4wspfuB2jLQ9j661gM' | ||
const decBigInt = dw58.decodeBigInt(encBigInt) // => 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n | ||
const encNegativeBigInt = dw58.encodeBigInt(negativeBigInt) // => '-K2G9r4Jq885HKagiU9oDmcFTBU7py6Q4UtvTJh86r4D384xCKkqvWtSNbXvLVcfzCNvgUw3fzCtFhiYwDmjf6s9XKHLmfxUFjbA9s1emfoWWkZ7uCi38gRzvr8wHK5FZQGtWYhDVXXmJa8sv85aNa4gksJkwN4wspfuB2jLQ9j661gM' | ||
const decNegativeBigInt = dw58.decodeBigInt(encNegativeBigInt) // => -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368n | ||
const encText = dw58.encodeText(text) // => 'HDmiyDYm3PDiZ4kmjkb' | ||
const decText = dw58.decodeText(encText) // => 'Ave, Darkwolf!' | ||
const encEmojis = dw58.encodeText(emojis) // => 'aQEoNWokSJmjEWmAe' | ||
const decEmojis = dw58.decodeText(encEmojis) // => '🐺🐺🐺' | ||
const encBuffer = dw58.encode(buffer) // => <Uint8Array 41 42 52 32 78 6e 73 33 33 42 76> | ||
const decBuffer = dw58.decode(encBuffer) // => <Uint8Array 00 02 04 08 0f 1f 3f 7f ff> | ||
``` | ||
## [API Documentation](https://github.com/Darkwolf/base58/blob/master/docs/API.md) | ||
## Donate | ||
#### You can contribute to the development of open source projects by making your donation 🐺 | ||
#### Bitcoin (BTC): `15sjjAUtJdB1ncsxKK7KtyJPtF46UhXWo4` | ||
#### Ethereum (ETH): `0xF02F68eb33E9eC73b8E9c3c0953E6782E2376867` | ||
#### Bitcoin Cash (BCH): `qq6h3a78h3wlt04eyp9ydht94r6guzjdps9hqwgfzw` | ||
## [API Documentation](https://github.com/Darkwolf/node-base58/blob/master/docs/API.md) | ||
## Contact Me | ||
@@ -27,0 +69,0 @@ #### GitHub: [@PavelWolfDark](https://github.com/PavelWolfDark) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
31398
752
0
1
72
1
6
1
+ Added@darkwolf/primordials@^1.1.9
+ Added@darkwolf/primordials@1.2.1(transitive)