blob: c52e356b3e798c7839c60066296e0178d36d0c25 (
plain)
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
|
/*
* base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers
*
* (C) 2010, Charlie Robbins & the Contributors.
*
*/
var base64 = exports;
//
// ### function encode (unencoded)
// #### @unencoded {string} The string to base64 encode
// Encodes the specified string to base64 using node.js Buffers.
//
base64.encode = function (unencoded) {
var encoded;
try {
encoded = new Buffer(unencoded || '').toString('base64');
}
catch (ex) {
return null;
}
return encoded;
};
//
// ### function decode (encoded)
// #### @encoded {string} The string to base64 decode
// Decodes the specified string from base64 using node.js Buffers.
//
base64.decode = function (encoded) {
var decoded;
try {
decoded = new Buffer(encoded || '', 'base64').toString('utf8');
}
catch (ex) {
return null;
}
return decoded;
};
|