Fixed base64 encoding bug
This commit is contained in:
parent
b8023389fd
commit
65296f31f5
2 changed files with 3 additions and 3 deletions
2
bitcoinjs-min.js
vendored
2
bitcoinjs-min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -21,7 +21,7 @@ module.exports.hexToBytes = function(hex) {
|
||||||
// Convert a byte array to a base-64 string
|
// Convert a byte array to a base-64 string
|
||||||
module.exports.bytesToBase64 = function(bytes) {
|
module.exports.bytesToBase64 = function(bytes) {
|
||||||
// Use browser-native function if it exists
|
// Use browser-native function if it exists
|
||||||
if (typeof btoa == "function") return btoa(Binary.bytesToString(bytes));
|
if (typeof btoa == "function") return btoa(module.exports.bytesToString(bytes));
|
||||||
|
|
||||||
for(var base64 = [], i = 0; i < bytes.length; i += 3) {
|
for(var base64 = [], i = 0; i < bytes.length; i += 3) {
|
||||||
var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
|
var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
|
||||||
|
@ -39,7 +39,7 @@ module.exports.bytesToBase64 = function(bytes) {
|
||||||
// Convert a base-64 string to a byte array
|
// Convert a base-64 string to a byte array
|
||||||
module.exports.base64ToBytes = function(base64) {
|
module.exports.base64ToBytes = function(base64) {
|
||||||
// Use browser-native function if it exists
|
// Use browser-native function if it exists
|
||||||
if (typeof atob == "function") return Binary.stringToBytes(atob(base64));
|
if (typeof atob == "function") return module.exports.stringToBytes(atob(base64));
|
||||||
|
|
||||||
// Remove non-base-64 characters
|
// Remove non-base-64 characters
|
||||||
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
|
base64 = base64.replace(/[^A-Z0-9+\/]/ig, "");
|
||||||
|
|
Loading…
Reference in a new issue