stephen-hill / base58php

Base58 Encoding and Decoding Library for PHP
MIT License
79 stars 19 forks source link

Illegal string in BCMathService #10

Closed jonaswebdev closed 9 years ago

jonaswebdev commented 9 years ago

Hi

Sometimes I see this warning, but when I try debug to find the problem, this warning don't happen again :( Do you know about this issue?

captura de tela 2015-06-30 10 41 35

Cheers

stephen-hill commented 9 years ago

Hi @jonaswebdev

What string are you trying to encode?

If you can provide me with a string, I'll be able to add it to the unit tests.

Currently I test the following string: https://github.com/stephen-hill/base58php/blob/master/tests/Base58Test.php#L38-L53

On the left is the string I want to encode, and on the right is the expected base58 encoding.

Cheers Stephen

stephen-hill commented 9 years ago

While I'm waiting for your response, other things you might want to think about:

Cheers Stephen

jonaswebdev commented 9 years ago

Hi Stephen,

let's go:

1) PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15) 2) OS X 10.9.4 3) I tried install GMP for avoid this issue, but I can't :( So, I'm using BCMath. 4) I can't run yet, but I will try now...

Cheers

stephen-hill commented 9 years ago

Thanks for the info.

Could you please give me a string which crashes it.

Cheers

jonaswebdev commented 9 years ago
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.

Runtime:    PHP 5.4.24
Configuration:  /Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/phpunit.xml
Warning:    Deprecated configuration setting "strict" used

..FFFFFFFFFFFFFFFFFFFFFF.....................................

Time: 6.67 seconds, Memory: 7.25Mb

There were 22 failures:

1) Base58Tests::testEncode with data set #2 ('1', 'r', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-r
+rr

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

2) Base58Tests::testEncode with data set #3 ('1', 'r', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-r
+rr

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

3) Base58Tests::testEncode with data set #4 ('a', '2g', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-2g
+22g

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

4) Base58Tests::testEncode with data set #5 ('a', '2g', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-2g
+22g

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

5) Base58Tests::testEncode with data set #6 ('bbb', 'a3gV', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-a3gV
+aa3gV

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

6) Base58Tests::testEncode with data set #7 ('bbb', 'a3gV', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-a3gV
+aa3gV

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

7) Base58Tests::testEncode with data set #8 ('ccc', 'aPEr', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-aPEr
+aaPEr

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

8) Base58Tests::testEncode with data set #9 ('ccc', 'aPEr', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-aPEr
+aaPEr

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

9) Base58Tests::testEncode with data set #10 ('hello!', 'tzCkV5Di', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-tzCkV5Di
+ttzCkV5Di

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

10) Base58Tests::testEncode with data set #11 ('hello!', 'tzCkV5Di', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-tzCkV5Di
+ttzCkV5Di

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

11) Base58Tests::testEncode with data set #12 ('Hello World', 'JxF12TrwUP45BMd', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-JxF12TrwUP45BMd
+JJxF12TrwUP45BMd

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

12) Base58Tests::testEncode with data set #13 ('Hello World', 'JxF12TrwUP45BMd', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-JxF12TrwUP45BMd
+JJxF12TrwUP45BMd

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

13) Base58Tests::testEncode with data set #14 ('this is a test', 'jo91waLQA1NNeBmZKUF', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-jo91waLQA1NNeBmZKUF
+jjo91waLQA1NNeBmZKUF

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

14) Base58Tests::testEncode with data set #15 ('this is a test', 'jo91waLQA1NNeBmZKUF', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-jo91waLQA1NNeBmZKUF
+jjo91waLQA1NNeBmZKUF

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

15) Base58Tests::testEncode with data set #16 ('the quick brown fox', 'NK2qR8Vz63NeeAJp9XRifbwahu', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-NK2qR8Vz63NeeAJp9XRifbwahu
+NNK2qR8Vz63NeeAJp9XRifbwahu

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

16) Base58Tests::testEncode with data set #17 ('the quick brown fox', 'NK2qR8Vz63NeeAJp9XRifbwahu', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-NK2qR8Vz63NeeAJp9XRifbwahu
+NNK2qR8Vz63NeeAJp9XRifbwahu

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

17) Base58Tests::testEncode with data set #18 ('THE QUICK BROWN FOX', 'GRvKwF9B69ssT67JgRWxPQTZ2X', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-GRvKwF9B69ssT67JgRWxPQTZ2X
+GGRvKwF9B69ssT67JgRWxPQTZ2X

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

18) Base58Tests::testEncode with data set #19 ('THE QUICK BROWN FOX', 'GRvKwF9B69ssT67JgRWxPQTZ2X', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-GRvKwF9B69ssT67JgRWxPQTZ2X
+GGRvKwF9B69ssT67JgRWxPQTZ2X

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

19) Base58Tests::testEncode with data set #20 ('simply a long string', '2cFupjhnEsSn59qHXstmK2ffpLv2', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-2cFupjhnEsSn59qHXstmK2ffpLv2
+22cFupjhnEsSn59qHXstmK2ffpLv2

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

20) Base58Tests::testEncode with data set #21 ('simply a long string', '2cFupjhnEsSn59qHXstmK2ffpLv2', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-2cFupjhnEsSn59qHXstmK2ffpLv2
+22cFupjhnEsSn59qHXstmK2ffpLv2

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

21) Base58Tests::testEncode with data set #22 (Binary String: 0x0061, '12g', StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-12g
+122g

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

22) Base58Tests::testEncode with data set #23 (Binary String: 0x0061, '12g', StephenHill\Base58 Object (...), StephenHill\Base58 Object (...))
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-12g
+122g

/Users/jonasrosado//...[my project patch].../vendor/stephenhill/base58/tests/Base58Test.php:17

FAILURES!
Tests: 61, Assertions: 66, Failures: 22.
jonaswebdev commented 9 years ago

Hi,

I sent my tests results, I hope that can help it :)

About a specific string that where i found a issue, it's a simple email address, see:

string(8) "username" string(19) "username@domain.com"

string(14) "username_coded" string(27) "NNW79kirxN5L4bfynMmYkBjc1NL"

string(16) "username_decoded" string(20) "r›‚ND7WÇDàP||#¢com"

stephen-hill commented 9 years ago

Thanks very much. Something going very wrong here. I will look into it as soon as I can.

I may come back to you to test some code for me because I don't have access to a Mac. Is that ok?

Cheers Stephen

jonaswebdev commented 9 years ago

Sure, just send me :)

But a thing that I don't understand is why BCmath doesn't works correctly, it should work in the same way in any environment, right?

Cheers

stephen-hill commented 9 years ago

Hi @jonaswebdev

I too am very confused why BCmath doesn't appear to work. The two functions being called are bcdiv() and bcmod(), both only return integers.

Anyway, I would be very grateful if you could run the following code.

<?php

$string = 'Hello World';
var_dump($string);

// Type validation
if (is_string($string) === false) {
    throw new InvalidArgumentException('Argument $string must be a string.');
}

// If the string is empty, then the encoded string is obviously empty
if (strlen($string) === 0) {
    return '';
}

// Strings in PHP are essentially 8-bit byte arrays
// so lets convert the string into a PHP array
$bytes = array_values(unpack('C*', $string));

var_dump(unpack('C*', $string));
var_dump($bytes);

// Now we need to convert the byte array into an arbitrary-precision decimal
// We basically do this by performing a base256 to base10 conversion
$decimal = $bytes[0];
var_dump($decimal);

for ($i = 1, $l = count($bytes); $i < $l; $i++) {
    $decimal = bcmul($decimal, 256);
    var_dump($decimal);
    $decimal = bcadd($decimal, $bytes[$i]);
    var_dump($decimal);
}

// This loop now performs base 10 to base 58 conversion
// The remainder or modulo on each loop becomes a base 58 character
$base = 58;
$alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
$output = '';
while ($decimal >= $base) {
    var_dump($decimal);
    $div = bcdiv($decimal, $base);
    var_dump($div);
    $mod = bcmod($decimal, $base);
    var_dump($mod);
    $output .= $alphabet[$mod];
    var_dump($alphabet[$mod]);
    var_dump($output);
    $decimal = $div;
    var_dump($decimal);
}

// If there's still a remainder, append it
var_dump($decimal > 0);
if ($decimal > 0) {
    $output .= $alphabet[$decimal];
    var_dump($alphabet[$decimal]);
    var_dump($output);
}

// Now we need to reverse the encoded data
$output = strrev($output);
var_dump($output);

// Now we need to add leading zeros
foreach ($bytes as $byte) {
    var_dump($byte);
    var_dump($byte === 0);
    if ($byte === 0) {
        $output = $alphabet[0] . $output;
        var_dump($alphabet[0]);
        var_dump($output);
        continue;
    }
    break;
}

var_dump($output);

The final var_dump should output "JxF12TrwUP45BMd". Please paste the full output.

I have updated the code to v1.1.3, so also please update to this version and run phpunit again.

Many Thanks Stephen

jonaswebdev commented 9 years ago

Hi @stephen-hill , sorry by delay, follow my output:

string(11) "Hello World"
array(11) {
  [1]=>
  int(72)
  [2]=>
  int(101)
  [3]=>
  int(108)
  [4]=>
  int(108)
  [5]=>
  int(111)
  [6]=>
  int(32)
  [7]=>
  int(87)
  [8]=>
  int(111)
  [9]=>
  int(114)
  [10]=>
  int(108)
  [11]=>
  int(100)
}
array(11) {
  [0]=>
  int(72)
  [1]=>
  int(101)
  [2]=>
  int(108)
  [3]=>
  int(108)
  [4]=>
  int(111)
  [5]=>
  int(32)
  [6]=>
  int(87)
  [7]=>
  int(111)
  [8]=>
  int(114)
  [9]=>
  int(108)
  [10]=>
  int(100)
}
int(72)
string(5) "18432"
string(5) "18533"
string(7) "4744448"
string(7) "4744556"
string(10) "1214606336"
string(10) "1214606444"
string(12) "310939249664"
string(12) "310939249775"
string(14) "79600447942400"
string(14) "79600447942432"
string(17) "20377714673262592"
string(17) "20377714673262679"
string(19) "5216694956355245824"
string(19) "5216694956355245935"
string(22) "1335473908826942959360"
string(22) "1335473908826942959474"
string(24) "341881320659697397625344"
string(24) "341881320659697397625452"
string(26) "87521618088882533792115712"
string(26) "87521618088882533792115812"
string(26) "87521618088882533792115812"
string(25) "1508993415325560927450272"
string(2) "36"
string(1) "d"
string(1) "d"
string(25) "1508993415325560927450272"
string(25) "1508993415325560927450272"
string(23) "26017127850440705645694"
string(2) "20"
string(1) "M"
string(2) "dM"
string(23) "26017127850440705645694"
string(23) "26017127850440705645694"
string(21) "448571169835184580098"
string(2) "10"
string(1) "B"
string(3) "dMB"
string(21) "448571169835184580098"
string(21) "448571169835184580098"
string(19) "7733985686813527243"
string(1) "4"
string(1) "5"
string(4) "dMB5"
string(19) "7733985686813527243"
string(19) "7733985686813527243"
string(18) "133344580807129780"
string(1) "3"
string(1) "4"
string(5) "dMB54"
string(18) "133344580807129780"
string(18) "133344580807129780"
string(16) "2299044496674651"
string(2) "22"
string(1) "P"
string(6) "dMB54P"
string(16) "2299044496674651"
string(16) "2299044496674651"
string(14) "39638698218528"
string(2) "27"
string(1) "U"
string(7) "dMB54PU"
string(14) "39638698218528"
string(14) "39638698218528"
string(12) "683425831353"
string(2) "54"
string(1) "w"
string(8) "dMB54PUw"
string(12) "683425831353"
string(12) "683425831353"
string(11) "11783203988"
string(2) "49"
string(1) "r"
string(9) "dMB54PUwr"
string(11) "11783203988"
string(11) "11783203988"
string(9) "203158689"
string(2) "26"
string(1) "T"
string(10) "dMB54PUwrT"
string(9) "203158689"
string(9) "203158689"
string(7) "3502736"
string(1) "1"
string(1) "2"
string(11) "dMB54PUwrT2"
string(7) "3502736"
string(7) "3502736"
string(5) "60392"
string(1) "0"
string(1) "1"
string(12) "dMB54PUwrT21"
string(5) "60392"
string(5) "60392"
string(4) "1041"
string(2) "14"
string(1) "F"
string(13) "dMB54PUwrT21F"
string(4) "1041"
string(4) "1041"
string(2) "17"
string(2) "55"
string(1) "x"
string(14) "dMB54PUwrT21Fx"
string(2) "17"
bool(true)
string(1) "J"
string(15) "dMB54PUwrT21FxJ"
string(15) "JxF12TrwUP45BMd"
int(72)
bool(false)
string(15) "JxF12TrwUP45BMd"
jonaswebdev commented 9 years ago

Follow my new test results:

PHPUnit 4.7.6 by Sebastian Bergmann and contributors.

Runtime:    PHP 5.4.24
Configuration:  /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/phpunit.xml

...............EEEEEEEEEEEEE...............EEEEEEEEEEEEE.....

Time: 6.65 seconds, Memory: 6.25Mb

There were 26 errors:

1) Base58Tests::testEncode with data set #15 ('1', 'r', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

2) Base58Tests::testEncode with data set #16 ('a', '2g', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

3) Base58Tests::testEncode with data set #17 ('bbb', 'a3gV', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

4) Base58Tests::testEncode with data set #18 ('ccc', 'aPEr', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

5) Base58Tests::testEncode with data set #19 ('hello!', 'tzCkV5Di', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

6) Base58Tests::testEncode with data set #20 ('Hello World', 'JxF12TrwUP45BMd', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

7) Base58Tests::testEncode with data set #21 ('this is a test', 'jo91waLQA1NNeBmZKUF', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

8) Base58Tests::testEncode with data set #22 ('the quick brown fox', 'NK2qR8Vz63NeeAJp9XRifbwahu', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

9) Base58Tests::testEncode with data set #23 ('THE QUICK BROWN FOX', 'GRvKwF9B69ssT67JgRWxPQTZ2X', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

10) Base58Tests::testEncode with data set #24 ('simply a long string', '2cFupjhnEsSn59qHXstmK2ffpLv2', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

11) Base58Tests::testEncode with data set #25 (Binary String: 0x0061, '12g', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

12) Base58Tests::testEncode with data set #26 (Binary String: 0x00, '1', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

13) Base58Tests::testEncode with data set #27 (Binary String: 0x0000, '11', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 70

14) Base58Tests::testDecode with data set #15 ('1', 'r', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

15) Base58Tests::testDecode with data set #16 ('a', '2g', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

16) Base58Tests::testDecode with data set #17 ('bbb', 'a3gV', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

17) Base58Tests::testDecode with data set #18 ('ccc', 'aPEr', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

18) Base58Tests::testDecode with data set #19 ('hello!', 'tzCkV5Di', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

19) Base58Tests::testDecode with data set #20 ('Hello World', 'JxF12TrwUP45BMd', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

20) Base58Tests::testDecode with data set #21 ('this is a test', 'jo91waLQA1NNeBmZKUF', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

21) Base58Tests::testDecode with data set #22 ('the quick brown fox', 'NK2qR8Vz63NeeAJp9XRifbwahu', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

22) Base58Tests::testDecode with data set #23 ('THE QUICK BROWN FOX', 'GRvKwF9B69ssT67JgRWxPQTZ2X', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

23) Base58Tests::testDecode with data set #24 ('simply a long string', '2cFupjhnEsSn59qHXstmK2ffpLv2', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

24) Base58Tests::testDecode with data set #25 (Binary String: 0x0061, '12g', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

25) Base58Tests::testDecode with data set #26 (Binary String: 0x00, '1', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

26) Base58Tests::testDecode with data set #27 (Binary String: 0x0000, '11', StephenHill\Base58 Object (...))
PHPUnit_Framework_Exception: PHP Fatal error:  Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131
Fatal error: Call to undefined function StephenHill\gmp_init() in /Users/jonasrosado/..[my project]../httpdocs/vendor/stephenhill/base58/src/GMPService.php on line 131

FAILURES!
Tests: 61, Assertions: 40, Errors: 26.
stephen-hill commented 9 years ago

@jonaswebdev The output of that script looks correct. So on the face of it, the BCMath extension is working and converting to base58.

PHPUnit is failing because you don't have the GMP extension enabled or installed. But I wouldn't worry about that.

You don't need GMP installed, the library will choose which ever (BCMath or GMP) is installed.

I would suggest that you continue using this libary in your project (with the latest version) and let me know if you have any further problems.

If it does throw an Illegal string offset error again, then let me know. Although I will need the exact string you passed to the encode or decode method.

Cheers Stephen

jonaswebdev commented 9 years ago

Stephen,

Great, thanks :)

I saw a new error in our logs, I created a pull request to I can analyze this better, see: https://github.com/stephen-hill/base58php/pull/11

Thanks a lot again!

stephen-hill commented 9 years ago

Thanks for the pull request.

I'll review it over the weekend. I like the idea though and might flesh it out a bit to more to display a bit more information (such as the exact Unicode value of the invalid character).

Many Thanks Stephen