FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
feathercore-lib/lib/encoding/base58.js at master · FeatherCoin/feathercore-lib · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
FeatherCoin
/
feathercore-lib
Public
forked from
bitpay/bitcore-lib
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
feathercore-lib
/
lib
/
encoding
/
base58.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (58 loc) · 1.5 KB
Breadcrumbs
feathercore-lib
/
lib
/
encoding
/
base58.js
Copy path
File metadata and controls
70 lines (58 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
'use strict'
;
var
_
=
require
(
'lodash'
)
;
var
bs58
=
require
(
'bs58'
)
;
var
buffer
=
require
(
'buffer'
)
;
var
ALPHABET
=
'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
.
split
(
''
)
;
var
Base58
=
function
Base58
(
obj
)
{
/* jshint maxcomplexity: 8 */
if
(
!
(
this
instanceof
Base58
)
)
{
return
new
Base58
(
obj
)
;
}
if
(
Buffer
.
isBuffer
(
obj
)
)
{
var
buf
=
obj
;
this
.
fromBuffer
(
buf
)
;
}
else
if
(
typeof
obj
===
'string'
)
{
var
str
=
obj
;
this
.
fromString
(
str
)
;
}
else
if
(
obj
)
{
this
.
set
(
obj
)
;
}
}
;
Base58
.
validCharacters
=
function
validCharacters
(
chars
)
{
if
(
buffer
.
Buffer
.
isBuffer
(
chars
)
)
{
chars
=
chars
.
toString
(
)
;
}
return
_
.
all
(
_
.
map
(
chars
,
function
(
char
)
{
return
_
.
contains
(
ALPHABET
,
char
)
;
}
)
)
;
}
;
Base58
.
prototype
.
set
=
function
(
obj
)
{
this
.
buf
=
obj
.
buf
||
this
.
buf
||
undefined
;
return
this
;
}
;
Base58
.
encode
=
function
(
buf
)
{
if
(
!
buffer
.
Buffer
.
isBuffer
(
buf
)
)
{
throw
new
Error
(
'Input should be a buffer'
)
;
}
return
bs58
.
encode
(
buf
)
;
}
;
Base58
.
decode
=
function
(
str
)
{
if
(
typeof
str
!==
'string'
)
{
throw
new
Error
(
'Input should be a string'
)
;
}
return
new
Buffer
(
bs58
.
decode
(
str
)
)
;
}
;
Base58
.
prototype
.
fromBuffer
=
function
(
buf
)
{
this
.
buf
=
buf
;
return
this
;
}
;
Base58
.
prototype
.
fromString
=
function
(
str
)
{
var
buf
=
Base58
.
decode
(
str
)
;
this
.
buf
=
buf
;
return
this
;
}
;
Base58
.
prototype
.
toBuffer
=
function
(
)
{
return
this
.
buf
;
}
;
Base58
.
prototype
.
toString
=
function
(
)
{
return
Base58
.
encode
(
this
.
buf
)
;
}
;
module
.
exports
=
Base58
;
Back
|
FazBrowse Home
|
New Git URL