Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / utile / lib / base64.js
1 /*
2  * base64.js: An extremely simple implementation of base64 encoding / decoding using node.js Buffers
3  *
4  * (C) 2010, Nodejitsu Inc.
5  *
6  */
7
8 var base64 = exports;
9
10 //
11 // ### function encode (unencoded)
12 // #### @unencoded {string} The string to base64 encode
13 // Encodes the specified string to base64 using node.js Buffers.
14 //
15 base64.encode = function (unencoded) {
16   var encoded;
17
18   try {
19     encoded = new Buffer(unencoded || '').toString('base64');
20   }
21   catch (ex) {
22     return null;
23   }
24
25   return encoded;
26 };
27
28 //
29 // ### function decode (encoded)
30 // #### @encoded {string} The string to base64 decode
31 // Decodes the specified string from base64 using node.js Buffers.
32 //
33 base64.decode = function (encoded) {
34   var decoded;
35
36   try {
37     decoded = new Buffer(encoded || '', 'base64').toString('utf8');
38   }
39   catch (ex) {
40     return null;
41   }
42
43   return decoded;
44 };