2018-04-14 23:10:26 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-06-13 22:39:39 +03:00
|
|
|
import convert = require('./convert');
|
2018-04-14 23:10:26 +03:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
decode: function(textData) {
|
|
|
|
textData = atob(textData);
|
|
|
|
var data = [];
|
|
|
|
for (var i = 0; i < textData.length; i++) {
|
|
|
|
data.push(textData.charCodeAt(i));
|
|
|
|
}
|
|
|
|
return convert.arrayify(data);
|
|
|
|
},
|
|
|
|
encode: function(data) {
|
|
|
|
data = convert.arrayify(data);
|
|
|
|
var textData = '';
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
textData += String.fromCharCode(data[i]);
|
|
|
|
}
|
|
|
|
return btoa(textData);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|