Code Monkey home page Code Monkey logo

base58's People

Contributors

mattallty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

isfpcn rxmg

base58's Issues

Incorrect information in documentation

In the documentation you state

... Base-58 contains alphanumeric characters minus "1" (number 1) ...

However looking at the $alphabet value I see the number 1.

    static $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';

Wrong base

The script as it stands with the following:

static $alphabet = '23456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
const BASE = 58;

I ran a test of sequential numbers and here is what I found.

$i : encode($i) => decode(encode($i))

0 : => 0         // ERROR
1 : 3 => 1
2 : 4 => 2
3 : 5 => 3
4 : 6 => 4
.
.
.
57 : => 0 // ERROR
.
.
114 : 3Z => 114
115 : 3 => 1  // ERROR
116 : 42 => 116
.
.
172 : 4Z => 17
173 : 4 => 2  // ERROR
174 : 52 => 174

Here are my observations:
Changing to BASE 56 works but doing so will work but you could not encode 0 and Z would never be used

0 : => 0 // ERROR
1 : 3 => 1
2 : 4 => 2
.
.
54 : X => 54
55 : Y => 55  
56 : 32 => 56  // Z is never used
57 : 33 => 57
.
.
110 : 3X => 110
111 : 3Y => 111 // Z is never used
112 : 42 => 112
113 : 43 => 113

Im using simpletest to run these numbers

        while($i < 1000)
        {
            $this->assertEqual($i, Base58::decode(Base58::encode($i)));
            echo '<br>' . $i . ' : ' . Base58::encode($i) . ' => ' . Base58::decode(Base58::encode($i));
            $i++;
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.