Skip to content

Commit

Permalink
fixes web3p#21 and web3p#22 Invalid RLP issues
Browse files Browse the repository at this point in the history
  • Loading branch information
olegabr committed May 24, 2021
1 parent 938a27a commit 6ac6613
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Types/Str.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ static function encode(string $input, string $encoding='utf8')
case 'utf8':
$outputs = unpack('C*', $input);
foreach ($outputs as $src) {
$output .= dechex($src);
$hex_src = dechex($src);
$hex_src_len = mb_strlen($hex_src);
if ($hex_src_len > 0 && $hex_src_len % 2 !== 0) {
$hex_src = '0' . $hex_src;
}
$output .= $hex_src;
}
break;
default:
Expand Down

0 comments on commit 6ac6613

Please sign in to comment.