Skip to content

Commit

Permalink
fix base64 display bug ECKey.toString missing pad
Browse files Browse the repository at this point in the history
  • Loading branch information
coretechs committed Mar 11, 2012
1 parent d2ba280 commit 0ebfba0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bitaddress.org.html
Original file line number Diff line number Diff line change
Expand Up @@ -3797,8 +3797,13 @@

ECKey.prototype.toString = function (format) {
format = format || "";
// Get a copy of private key as a byte array
var bytes = this.priv.toByteArrayUnsigned();
// zero pad if private key is less than 32 bytes
while (bytes.length < 32) bytes.unshift(0x00);

if (format === "base64" || format === "b64") {
return Crypto.util.bytesToBase64(this.priv.toByteArrayUnsigned());
return Crypto.util.bytesToBase64(bytes);
}
// Wallet Import Format
else if (format.toString().toLowerCase() == "wif") {
Expand Down

0 comments on commit 0ebfba0

Please sign in to comment.