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

bs58

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bs58 - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

5

CHANGELOG.md

@@ -0,1 +1,6 @@

0.2.1 / 2014-02-24
------------------
* removed bower and component support. Closes #1
* convert from 4 spaces to 2
0.2.0 / 2013-12-07

@@ -2,0 +7,0 @@ ------------------

89

lib/bs58.js

@@ -1,16 +0,9 @@

!function(globals) {
var BigInteger = require('bigi');
'use strict'
var BigInteger = null
var base58 = {} //exports
module.exports.decode = decode;
module.exports.encode = encode;
if (typeof module !== 'undefined' && module.exports) { //CommonJS
BigInteger = require('bigi')
module.exports = base58
} else {
BigInteger = globals.BigInteger
globals.bs58 = base58
}
var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";

@@ -21,35 +14,28 @@ var base = BigInteger.valueOf(58);

for (var i=0 ; i < alphabet.length ; ++i) {
positions[alphabet[i]] = i;
positions[alphabet[i]] = i;
}
// Convert a byte array to a base58-encoded string.
// Written by Mike Hearn for BitcoinJ.
// Copyright (c) 2011 Google Inc.
// Ported to JavaScript by Stefan Thomas.
base58.encode = function (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
function encode (input) {
var bi = BigInteger.fromByteArrayUnsigned(input);
var chars = [];
while (bi.compareTo(base) >= 0) {
var mod = bi.mod(base);
chars.push(alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(base);
}
chars.push(alphabet[bi.intValue()]);
while (bi.compareTo(base) >= 0) {
var mod = bi.mod(base);
chars.push(alphabet[mod.intValue()]);
bi = bi.subtract(mod).divide(base);
}
chars.push(alphabet[bi.intValue()]);
// Convert leading zeros too.
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x00) {
chars.push(alphabet[0]);
} else break;
}
// Convert leading zeros too.
for (var i = 0; i < input.length; i++) {
if (input[i] == 0x00) {
chars.push(alphabet[0]);
} else break;
}
return chars.reverse().join('');
return chars.reverse().join('');
}
// decode a base58 string into a byte array
// input should be a base58 encoded string
// @return Array
base58.decode = function (input) {
function decode (input) {
var base = BigInteger.valueOf(58);

@@ -62,18 +48,18 @@

for (var i=0; i<length ; ++i) {
var char = input[i];
var p = positions[char];
var char = input[i];
var p = positions[char];
// if we encounter an invalid character, decoding fails
if (p === undefined) {
throw new Error('invalid base58 string: ' + input);
}
// if we encounter an invalid character, decoding fails
if (p === undefined) {
throw new Error('invalid base58 string: ' + input);
}
num = num.multiply(base).add(BigInteger.valueOf(p));
num = num.multiply(base).add(BigInteger.valueOf(p));
if (char == '1' && !seen_other) {
++leading_zero;
}
else {
seen_other = true;
}
if (char == '1' && !seen_other) {
++leading_zero;
}
else {
seen_other = true;
}
}

@@ -85,3 +71,3 @@

while (leading_zero-- > 0) {
bytes.unshift(0);
bytes.unshift(0);
}

@@ -91,4 +77,1 @@

}
}(this);
{
"name": "bs58",
"version": "0.2.0",
"version": "0.2.1",
"description": "Base58 check encoding",

@@ -5,0 +5,0 @@ "keywords": [

bs58
===
JavaScript component to compute [Base58](https://en.bitcoin.it/wiki/Base58Check_encoding) check encoding for Bitcoin.
JavaScript component to compute [Base58](https://en.bitcoin.it/wiki/Base58Check_encoding) check encoding for Bitcoin. See this article for more details: [bitcoin address](http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript).
AMD/CommonJS compatible.
See this article for more details: [bitcoin address](http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript).
Usage
-----
### Installation
Install
-------
### Node.js/Browserify
npm install --save bs58
### Component
component install cryptocoinjs/bs58
Api
---
### Bower
bower install bs58
### Script
```html
<script src="/path/to/bs58.js"></script>
```
Usage
-----
### encode(arrayOfBytes)

@@ -55,3 +35,2 @@

Copyright 2013, JP Richardson <jprichardson@gmail.com>

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