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

@darkwolf/base58

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/base58 - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

.gitattributes

50

index.js
class Base58 {
constructor(alphabet) {
this.alphabet = alphabet || 'AveDarkwo1f23456789BCEFGHJKLMNPQRSTUVWXYZbcdghijmnpqstuxyz'
this.DARKWOLF_ALPHABET = 'AveDarkwo1f23456789BCEFGHJKLMNPQRSTUVWXYZbcdghijmnpqstuxyz'
this.BITCOIN_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
this.RIPPLE_ALPHABET = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
this.alphabet = alphabet || this.DARKWOLF_ALPHABET
this.Base58 = Base58
}
encode(string) {
return string.split('').map(o => o.charCodeAt()).reduce((d, c, i) => {
encode(input) {
const buffer = Buffer.isBuffer(input) ? input : Buffer.from(input)
return buffer.reduce((bytes, carry, i) => {
if (!(carry || bytes.length ^ i)) bytes.push(1)
let j = 0
let n
if (!(c || d.length ^ i)) d.push(1)
while (j in d || c) {
n = d[j]
n = n ? n * 256 + c : c
c = n / 58 | 0
d[j] = n % 58
while (j in bytes || carry) {
let byte = bytes[j]
byte = byte ? byte * 256 + carry : carry
bytes[j] = byte % 58
carry = byte / 58 | 0
j++
}
return d
return bytes
}, []).reverse().map(o => this.alphabet[o]).join('')
}
decode(string) {
return String.fromCharCode(...string.split('').map(o => this.alphabet.indexOf(o)).reduce((d, c, i) => {
decode(input) {
const string = Buffer.isBuffer(input) ? input.toString() : input
return String.fromCharCode(...string.split('').map(o => this.alphabet.indexOf(o)).reduce((bytes, carry, i) => {
if (!(carry || bytes.length ^ i)) bytes.push(0)
let j = 0
let n
if (!(c || d.length ^ i)) d.push(0)
while (j in d || c) {
n = d[j]
n = n ? n * 58 + c : c
c = n >> 8
d[j] = n % 256
while (j in bytes || carry) {
let byte = bytes[j]
byte = byte ? byte * 58 + carry : carry
bytes[j] = byte % 256
carry = byte >> 8
j++
}
return d
return bytes
}, []).reverse())

@@ -37,0 +45,0 @@ }

{
"name": "@darkwolf/base58",
"version": "1.0.2",
"description": "Base58",
"version": "1.0.3",
"description": "Base58 Encoder/Decoder",
"main": "index.js",

@@ -14,3 +14,5 @@ "scripts": {

"keywords": [
"base58"
"base58",
"encoder",
"decoder"
],

@@ -17,0 +19,0 @@ "author": "Pavel Wolf",

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