forked from svrjs/svrjs
Update to SVR.JS 3.4.32
This commit is contained in:
parent
85bc805219
commit
9bd93966e4
33 changed files with 39 additions and 1443 deletions
Binary file not shown.
Before Width: | Height: | Size: 243 B |
|
@ -1,124 +0,0 @@
|
||||||
//Base64.js for hexstrbase64 library for Node.js
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2012 Miles Shang <mail@mshang.ca>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included
|
|
||||||
* in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Usage:
|
|
||||||
* Set your settings:
|
|
||||||
* base64.settings.char62 = "-";
|
|
||||||
* base64.settings.char63 = "_";
|
|
||||||
* etc.
|
|
||||||
*
|
|
||||||
* Then:
|
|
||||||
* base64.encode(str) takes a string and returns the base64 encoding of it.
|
|
||||||
* base64.decode(str) does the reverse.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* Add a "padding_mandatory" flag to check for bad padding in the decoder.
|
|
||||||
* Add test cases that throw errors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var base64 = new Object();
|
|
||||||
|
|
||||||
base64.settings = { // defaults
|
|
||||||
"char62" : "+",
|
|
||||||
"char63" : "/",
|
|
||||||
"pad" : "=",
|
|
||||||
"ascii" : false
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Settings:
|
|
||||||
* If "pad" is not null or undefined, then it will be used for encoding.
|
|
||||||
*
|
|
||||||
* If "ascii" is set to true, then the encoder
|
|
||||||
* will assume that plaintext is in 8-bit chars (the standard).
|
|
||||||
* In this case, for every 3 chars in plaintext, you get 4 chars of base64.
|
|
||||||
* Any non-8-bit chars will cause an error.
|
|
||||||
* Otherwise, assume that all plaintext can be in the full range
|
|
||||||
* of Javascript chars, i.e. 16 bits. Get 8 chars of base64 for 3 chars
|
|
||||||
* of plaintext. Any possible JS string can be encoded.
|
|
||||||
*/
|
|
||||||
|
|
||||||
base64.encode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
var c_num = str.charCodeAt(i);
|
|
||||||
if (this.settings.ascii)
|
|
||||||
if (c_num >= 256)
|
|
||||||
throw "Not an 8-bit char.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < (this.settings.ascii ? 8 : 16))
|
|
||||||
c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= 6) {
|
|
||||||
var sextet = buf.slice(0, 6);
|
|
||||||
buf = buf.slice(6);
|
|
||||||
output += this.char_set.charAt(parseInt(sextet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf) { // not empty
|
|
||||||
while (buf.length < 6) buf += "0";
|
|
||||||
output += this.char_set.charAt(parseInt(buf, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.settings.pad)
|
|
||||||
while (output.length % (this.settings.ascii ? 4 : 8) != 0)
|
|
||||||
output += this.settings.pad;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
base64.decode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
var bits = (this.settings.ascii ? 8 : 16);
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
if (str[i] == this.settings.pad) break;
|
|
||||||
var c_num = this.char_set.indexOf(str.charAt(i));
|
|
||||||
if (c_num == -1) throw "Not base64.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < 6) c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= bits) {
|
|
||||||
var octet = buf.slice(0, bits);
|
|
||||||
buf = buf.slice(bits);
|
|
||||||
output += String.fromCharCode(parseInt(octet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
module.exports = base64;
|
|
|
@ -1,123 +0,0 @@
|
||||||
//Base64.js for hexstrbase64 library for browser
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2012 Miles Shang <mail@mshang.ca>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included
|
|
||||||
* in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Usage:
|
|
||||||
* Set your settings:
|
|
||||||
* base64.settings.char62 = "-";
|
|
||||||
* base64.settings.char63 = "_";
|
|
||||||
* etc.
|
|
||||||
*
|
|
||||||
* Then:
|
|
||||||
* base64.encode(str) takes a string and returns the base64 encoding of it.
|
|
||||||
* base64.decode(str) does the reverse.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* Add a "padding_mandatory" flag to check for bad padding in the decoder.
|
|
||||||
* Add test cases that throw errors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var base64 = new Object();
|
|
||||||
|
|
||||||
base64.settings = { // defaults
|
|
||||||
"char62" : "+",
|
|
||||||
"char63" : "/",
|
|
||||||
"pad" : "=",
|
|
||||||
"ascii" : false
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Settings:
|
|
||||||
* If "pad" is not null or undefined, then it will be used for encoding.
|
|
||||||
*
|
|
||||||
* If "ascii" is set to true, then the encoder
|
|
||||||
* will assume that plaintext is in 8-bit chars (the standard).
|
|
||||||
* In this case, for every 3 chars in plaintext, you get 4 chars of base64.
|
|
||||||
* Any non-8-bit chars will cause an error.
|
|
||||||
* Otherwise, assume that all plaintext can be in the full range
|
|
||||||
* of Javascript chars, i.e. 16 bits. Get 8 chars of base64 for 3 chars
|
|
||||||
* of plaintext. Any possible JS string can be encoded.
|
|
||||||
*/
|
|
||||||
|
|
||||||
base64.encode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
var c_num = str.charCodeAt(i);
|
|
||||||
if (this.settings.ascii)
|
|
||||||
if (c_num >= 256)
|
|
||||||
throw "Not an 8-bit char.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < (this.settings.ascii ? 8 : 16))
|
|
||||||
c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= 6) {
|
|
||||||
var sextet = buf.slice(0, 6);
|
|
||||||
buf = buf.slice(6);
|
|
||||||
output += this.char_set.charAt(parseInt(sextet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf) { // not empty
|
|
||||||
while (buf.length < 6) buf += "0";
|
|
||||||
output += this.char_set.charAt(parseInt(buf, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.settings.pad)
|
|
||||||
while (output.length % (this.settings.ascii ? 4 : 8) != 0)
|
|
||||||
output += this.settings.pad;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
base64.decode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
var bits = (this.settings.ascii ? 8 : 16);
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
if (str[i] == this.settings.pad) break;
|
|
||||||
var c_num = this.char_set.indexOf(str.charAt(i));
|
|
||||||
if (c_num == -1) throw "Not base64.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < 6) c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= bits) {
|
|
||||||
var octet = buf.slice(0, bits);
|
|
||||||
buf = buf.slice(bits);
|
|
||||||
output += String.fromCharCode(parseInt(octet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
//Requires base64
|
|
||||||
var base64 = require('./base64.js');
|
|
||||||
var HexStrBase64Buffer = {
|
|
||||||
from: function(s, e) {
|
|
||||||
var type = e;
|
|
||||||
var value = '';
|
|
||||||
if (e == 'base64') {
|
|
||||||
value = base64.decode(s);
|
|
||||||
} else if (e == 'hex') {
|
|
||||||
try {
|
|
||||||
var escaped = "";
|
|
||||||
var hex = "";
|
|
||||||
if(s.length%4 > 0) {
|
|
||||||
for(i=0;i<(4-(s.length%4));i++) {
|
|
||||||
hex += "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hex += s;
|
|
||||||
for(var i = 0;i<hex.length;i += 4) {
|
|
||||||
escaped += new String("%u" + hex.charAt(i) + hex.charAt(i + 1) + hex.charAt(i + 2) + hex.charAt(i + 3)).toString().split("undefined").join("");
|
|
||||||
}
|
|
||||||
value = unescape(escaped).split(unescape("%00")).join("");
|
|
||||||
} catch (ex) {
|
|
||||||
var modex = ex.toString().split('Error: ');
|
|
||||||
modex[0] = '';
|
|
||||||
if (typeof modex == 'object') {
|
|
||||||
throw new Error(
|
|
||||||
'Invaild hex input: ' + s + '. Reason: ' + modex.join('')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new Error('Invaild hex input: ' + s + '. Reason: ' + ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value = Buffer.from(s, 'utf8').toString(e);
|
|
||||||
}
|
|
||||||
function toString(en) {
|
|
||||||
//function toStringE(en,type) {
|
|
||||||
if (en == 'base64') {
|
|
||||||
return base64.encode(value);
|
|
||||||
} else if (en == 'hex') {
|
|
||||||
var result = "";
|
|
||||||
for(var i=0;i<value.length;i++) {
|
|
||||||
var unicode = escape(value.charAt(i));
|
|
||||||
var hex = "";
|
|
||||||
if(value.charAt(i) == "\n") {
|
|
||||||
hex = "000a";
|
|
||||||
} else if(value.charAt(i) == "\r") {
|
|
||||||
hex = "000d";
|
|
||||||
} else if(value.charAt(i) == " ") {
|
|
||||||
hex = "0020";
|
|
||||||
} else if(value.charAt(i) == "\0") {
|
|
||||||
hex = "";
|
|
||||||
} else if(unicode == value.charAt(i)) {
|
|
||||||
var oldhex = value.charCodeAt(i).toString(16);
|
|
||||||
var newhex = "";
|
|
||||||
if(oldhex.length < 4) {
|
|
||||||
for(var j=0;j<4-(oldhex.length%4);j++) {
|
|
||||||
newhex += "0";
|
|
||||||
}
|
|
||||||
newhex += oldhex;
|
|
||||||
} else {
|
|
||||||
newhex = oldhex;
|
|
||||||
}
|
|
||||||
hex = newhex;
|
|
||||||
} else {
|
|
||||||
hex = unicode.split("%u").join("");
|
|
||||||
}
|
|
||||||
if(hex.length == 4 || hex === "") {
|
|
||||||
result += hex;
|
|
||||||
} else if(hex.length > 4) {
|
|
||||||
result += hex.substring(hex.length-5,hex.length-1);
|
|
||||||
} else if(hex.length < 4) {
|
|
||||||
for(var j=0;j<=4-(hex.length%4);j++) {
|
|
||||||
result += "0";
|
|
||||||
}
|
|
||||||
result += hex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.split("undefined").join("").split("%").join("");
|
|
||||||
} else {
|
|
||||||
//return Buffer.from(value, type).toString(en);
|
|
||||||
return Buffer.from(value,"utf8").toString(en);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
//function toString(en) {
|
|
||||||
//return toStringE(en,type);
|
|
||||||
//}
|
|
||||||
return { type: type, value: value, toString: toString };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var hexstrbase64 = {
|
|
||||||
strtobase64: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('base64');
|
|
||||||
},
|
|
||||||
base64tostr: function(b) {
|
|
||||||
return HexStrBase64Buffer.from(b, 'base64').toString('utf8');
|
|
||||||
},
|
|
||||||
strtohex: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('hex');
|
|
||||||
},
|
|
||||||
hextostr: function(h) {
|
|
||||||
return HexStrBase64Buffer.from(h, 'hex').toString('utf8');
|
|
||||||
},
|
|
||||||
hextobase64: function(h) {
|
|
||||||
return hexstrbase64.strtobase64(hexstrbase64.hextostr(h));
|
|
||||||
},
|
|
||||||
base64tohex: function(b) {
|
|
||||||
return hexstrbase64.strtohex(hexstrbase64.base64tostr(b));
|
|
||||||
},
|
|
||||||
cipher: function() {
|
|
||||||
this.strtobase64 = hexstrbase64.strtobase64;
|
|
||||||
this.base64tostr = hexstrbase64.base64tostr;
|
|
||||||
this.strtohex = hexstrbase64.strtohex;
|
|
||||||
this.hextostr = hexstrbase64.hextostr;
|
|
||||||
this.hextobase64 = hextobase64.hextobase64;
|
|
||||||
this.base64tohex = hextobase64.base64tohex;
|
|
||||||
},
|
|
||||||
native: {
|
|
||||||
btoa: function(b) {
|
|
||||||
return hexstrbase64.strtobase64(b);
|
|
||||||
},
|
|
||||||
atob: function(a) {
|
|
||||||
return hexstrbase64.base64tostr(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
module.exports = hexstrbase64;
|
|
|
@ -1,126 +0,0 @@
|
||||||
//Requires base64_browser.js
|
|
||||||
var HexStrBase64Buffer = {
|
|
||||||
from: function(s, e) {
|
|
||||||
var type = e;
|
|
||||||
var value = '';
|
|
||||||
if (e == 'base64') {
|
|
||||||
value = base64.decode(s);
|
|
||||||
} else if (e == 'hex') {
|
|
||||||
try {
|
|
||||||
var escaped = "";
|
|
||||||
var hex = "";
|
|
||||||
if(s.length%4 > 0) {
|
|
||||||
for(i=0;i<(4-(s.length%4));i++) {
|
|
||||||
hex += "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hex += s;
|
|
||||||
for(var i = 0;i<hex.length;i += 4) {
|
|
||||||
escaped += new String("%u" + hex.charAt(i) + hex.charAt(i + 1) + hex.charAt(i + 2) + hex.charAt(i + 3)).toString().split("undefined").join("");
|
|
||||||
}
|
|
||||||
value = unescape(escaped).split(unescape("%00")).join("");
|
|
||||||
} catch (ex) {
|
|
||||||
var modex = ex.toString().split('Error: ');
|
|
||||||
modex[0] = '';
|
|
||||||
if (typeof modex == 'object') {
|
|
||||||
throw new Error(
|
|
||||||
'Invaild hex input: ' + s + '. Reason: ' + modex.join('')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new Error('Invaild hex input: ' + s + '. Reason: ' + ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value = new TextDecoder(e).decode(new TextEncoder('utf8').encode(s));
|
|
||||||
}
|
|
||||||
//function toStringE(en,type) {
|
|
||||||
function toString(en) {
|
|
||||||
if (en == 'base64') {
|
|
||||||
return base64.encode(value);
|
|
||||||
} else if (en == 'hex') {
|
|
||||||
var result = "";
|
|
||||||
for(var i=0;i<value.length;i++) {
|
|
||||||
var unicode = escape(value.charAt(i));
|
|
||||||
var hex = "";
|
|
||||||
if(value.charAt(i) == "\n") {
|
|
||||||
hex = "000a";
|
|
||||||
} else if(value.charAt(i) == "\r") {
|
|
||||||
hex = "000d";
|
|
||||||
} else if(value.charAt(i) == " ") {
|
|
||||||
hex = "0020";
|
|
||||||
} else if(value.charAt(i) == "\0") {
|
|
||||||
hex = "";
|
|
||||||
} else if(unicode == value.charAt(i)) {
|
|
||||||
var oldhex = value.charCodeAt(i).toString(16);
|
|
||||||
var newhex = "";
|
|
||||||
if(oldhex.length < 4) {
|
|
||||||
for(var j=0;j<4-(oldhex.length%4);j++) {
|
|
||||||
newhex += "0";
|
|
||||||
}
|
|
||||||
newhex += oldhex;
|
|
||||||
} else {
|
|
||||||
newhex = oldhex;
|
|
||||||
}
|
|
||||||
hex = newhex;
|
|
||||||
} else {
|
|
||||||
hex = unicode.split("%u").join("");
|
|
||||||
}
|
|
||||||
if(hex.length == 4 || hex === "") {
|
|
||||||
result += hex;
|
|
||||||
} else if(hex.length > 4) {
|
|
||||||
result += hex.substring(hex.length-5,hex.length-1);
|
|
||||||
} else if(hex.length < 4) {
|
|
||||||
for(var j=0;j<=4-(hex.length%4);j++) {
|
|
||||||
result += "0";
|
|
||||||
}
|
|
||||||
result += hex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.split("undefined").join("").split("%").join("");
|
|
||||||
} else {
|
|
||||||
//return new TextDecoder(en).decode(new TextEncoder(type).encode(value));
|
|
||||||
return new TextDecoder(en).decode(new TextEncoder("utf8").encode(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//function toString(en) {
|
|
||||||
//return toStringE(en,type);
|
|
||||||
//}
|
|
||||||
return { type: type, value: value, toString: toString };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var hexstrbase64 = {
|
|
||||||
strtobase64: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('base64');
|
|
||||||
},
|
|
||||||
base64tostr: function(b) {
|
|
||||||
return HexStrBase64Buffer.from(b, 'base64').toString('utf8');
|
|
||||||
},
|
|
||||||
strtohex: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('hex');
|
|
||||||
},
|
|
||||||
hextostr: function(h) {
|
|
||||||
return HexStrBase64Buffer.from(h, 'hex').toString('utf8');
|
|
||||||
},
|
|
||||||
hextobase64: function(h) {
|
|
||||||
return hexstrbase64.strtobase64(hexstrbase64.hextostr(h));
|
|
||||||
},
|
|
||||||
base64tohex: function(b) {
|
|
||||||
return hexstrbase64.strtohex(hexstrbase64.base64tostr(b));
|
|
||||||
},
|
|
||||||
cipher: function() {
|
|
||||||
this.strtobase64 = hexstrbase64.strtobase64;
|
|
||||||
this.base64tostr = hexstrbase64.base64tostr;
|
|
||||||
this.strtohex = hexstrbase64.strtohex;
|
|
||||||
this.hextostr = hexstrbase64.hextostr;
|
|
||||||
this.hextobase64 = hextobase64.hextobase64;
|
|
||||||
this.base64tohex = hextobase64.base64tohex;
|
|
||||||
},
|
|
||||||
native: {
|
|
||||||
btoa: function(b) {
|
|
||||||
return hexstrbase64.strtobase64(b);
|
|
||||||
},
|
|
||||||
atob: function(a) {
|
|
||||||
return hexstrbase64.base64tostr(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,11 +0,0 @@
|
||||||
let hexstrbase64 = require("./hexstrbase64/main.js");
|
|
||||||
function decodeBase(b) {
|
|
||||||
return hexstrbase64.native.atob(b);
|
|
||||||
}
|
|
||||||
function encodeStr(s) {
|
|
||||||
return hexstrbase64.native.btoa(s);
|
|
||||||
}
|
|
||||||
var m = Object.create(hexstrbase64);
|
|
||||||
m.decodeBase = decodeBase;
|
|
||||||
m.encodeBase = encodeStr;
|
|
||||||
module.exports = m;
|
|
Binary file not shown.
Before Width: | Height: | Size: 252 B |
|
@ -1,8 +0,0 @@
|
||||||
.code {
|
|
||||||
border-width: 5px;
|
|
||||||
border-color: #BEBEBE;
|
|
||||||
border-style: solid;
|
|
||||||
color:black;
|
|
||||||
background-color: #7F7F7F;
|
|
||||||
font-family: Hack,Consolas,Monaco,monospace;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>HexStrBase64 Readme</title>
|
|
||||||
<link rel="stylesheet" href="readme.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>hexstrbase64</h1>
|
|
||||||
<h2>How to install?</h2>
|
|
||||||
<h3>Node.js</h3>
|
|
||||||
<ol>
|
|
||||||
<li>Download library from <a href="https://repl.it/@DorianNiemiec/Hex-String-Base64-NodeJS-Library.zip" download>here</a>.</li>
|
|
||||||
<li>Modify index.js</li>
|
|
||||||
<li>Write header in program (replace <b>./hexstrbase64</b> with your path to hexstrbase64 library):</li>
|
|
||||||
<div class="code">
|
|
||||||
var hexstrbase64 = require("<b>./hexstrbase64</b>/index.js");<br/>
|
|
||||||
</div>
|
|
||||||
<li>Now hexstrbase64 library added to program!</li>
|
|
||||||
</ol>
|
|
||||||
<h3>Browser Javascript</h3>
|
|
||||||
<ol>
|
|
||||||
<li>Download library from <a href="https://repl.it/@DorianNiemiec/Hex-String-Base64-NodeJS-Library.zip" download>here</a>.</li>
|
|
||||||
<li>Write this code in <head> element (replace <b>hexstrbase64/</b> with your path to hexstrbase64 library):</li>
|
|
||||||
<div class="code">
|
|
||||||
<script src="<b>hexstrbase64/</b>hexstrbase64/base64_browser.js"></script><br/>
|
|
||||||
<script src="<b>hexstrbase64/</b>hexstrbase64/main_browser.js"></script>
|
|
||||||
</div>
|
|
||||||
<li>Now hexstrbase64 library added to HTML!</li>
|
|
||||||
</ol>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>hexstrbase64 base64 test</title>
|
|
||||||
<script src="../hexstrbase64/base64_browser.js"></script>
|
|
||||||
<script src="../hexstrbase64/main_browser.js"></script>
|
|
||||||
<script src="base64.js"></script>
|
|
||||||
<script>
|
|
||||||
testStart();
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
|
@ -1,56 +0,0 @@
|
||||||
function nameObj(n, v) {
|
|
||||||
return {name:n, value:v};
|
|
||||||
}
|
|
||||||
|
|
||||||
function testStart() {
|
|
||||||
document.write('<meta charset="UTF-8">');
|
|
||||||
document.write('<title>hexstrbase64 base64 test</title>');
|
|
||||||
console.log("TESTING STARTED");
|
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
document.write('<h1>' + enccases[i].name + '</h1>');
|
|
||||||
console.log("SWITCH " + enccases[i].name);
|
|
||||||
for (var j = 0; j < 2; j++) {
|
|
||||||
document.write('<h2>' + enccases[i].value[j].name + '</h2>');
|
|
||||||
console.log("CASE " + enccases[i].value[j].name);
|
|
||||||
console.log("MUST BE: " + enccases[i].value[j].value);
|
|
||||||
console.log("IS : " + hexstrbase64.strtobase64(enccases[i].value[j].name));
|
|
||||||
if (hexstrbase64.strtobase64(enccases[i].value[j].name) == enccases[i].value[j].value) {
|
|
||||||
document.write('<p><img src="../ok.png"></img>Equals</p>');
|
|
||||||
console.log("EQUALS");
|
|
||||||
} else {
|
|
||||||
document.write('<p><img src="../fail.png"></img>Not Equals</p>');
|
|
||||||
console.log("NOT EQUALS");
|
|
||||||
}
|
|
||||||
console.log("CASE " + enccases[i].value[j].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("SWITCH " + enccases[i].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("TESTING ENDED");
|
|
||||||
}
|
|
||||||
|
|
||||||
var enccases = [
|
|
||||||
nameObj('Ascii', [
|
|
||||||
nameObj('Hello world!', 'AEgAZQBsAGwAbwAgAHcAbwByAGwAZAAh'),
|
|
||||||
nameObj('Lorem ipsum', 'AEwAbwByAGUAbQAgAGkAcABzAHUAbQ==')
|
|
||||||
]),
|
|
||||||
nameObj('Ascii More Than 64 Bytes', [
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum fermentum ac nisl a sollicitudin. Cras interdum dui turpis, non scelerisque.',
|
|
||||||
'AEwAbwByAGUAbQAgAGkAcABzAHUAbQAgAGQAbwBsAG8AcgAgAHMAaQB0ACAAYQBtAGUAdAAsACAAYwBvAG4AcwBlAGMAdABlAHQAdQByACAAYQBkAGkAcABpAHMAYwBpAG4AZwAgAGUAbABpAHQALgAgAFYAZQBzAHQAaQBiAHUAbAB1AG0AIABmAGUAcgBtAGUAbgB0AHUAbQAgAGEAYwAgAG4AaQBzAGwAIABhACAAcwBvAGwAbABpAGMAaQB0AHUAZABpAG4ALgAgAEMAcgBhAHMAIABpAG4AdABlAHIAZAB1AG0AIABkAHUAaQAgAHQAdQByAHAAaQBzACwAIABuAG8AbgAgAHMAYwBlAGwAZQByAGkAcwBxAHUAZQAu'
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dapibus volutpat ligula at pulvinar. Etiam consequat mi fringilla facilisis eleifend.',
|
|
||||||
'AEwAbwByAGUAbQAgAGkAcABzAHUAbQAgAGQAbwBsAG8AcgAgAHMAaQB0ACAAYQBtAGUAdAAsACAAYwBvAG4AcwBlAGMAdABlAHQAdQByACAAYQBkAGkAcABpAHMAYwBpAG4AZwAgAGUAbABpAHQALgAgAFAAaABhAHMAZQBsAGwAdQBzACAAZABhAHAAaQBiAHUAcwAgAHYAbwBsAHUAdABwAGEAdAAgAGwAaQBnAHUAbABhACAAYQB0ACAAcAB1AGwAdgBpAG4AYQByAC4AIABFAHQAaQBhAG0AIABjAG8AbgBzAGUAcQB1AGEAdAAgAG0AaQAgAGYAcgBpAG4AZwBpAGwAbABhACAAZgBhAGMAaQBsAGkAcwBpAHMAIABlAGwAZQBpAGYAZQBuAGQALg=='
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
nameObj('Unicode UTF8', [
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器',
|
|
||||||
'AEQAbwByAGkAYQBuAFQAZQBjAGgAIABIAGUAeAAgAFMAdAByAGkAbgBnACAAQgBhAHMAZQA2ADSPbGNiVmg====='
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器,用于由DorianTech提供的Node.js',
|
|
||||||
'AEQAbwByAGkAYQBuAFQAZQBjAGgAIABIAGUAeAAgAFMAdAByAGkAbgBnACAAQgBhAHMAZQA2ADSPbGNiVmj/DHUoTo51MQBEAG8AcgBpAGEAbgBUAGUAYwBoY9BPm3aEAE4AbwBkAGUALgBqAHM====='
|
|
||||||
)
|
|
||||||
])
|
|
||||||
];
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>hexstrbase64 hex test</title>
|
|
||||||
<script src="../hexstrbase64/base64_browser.js"></script>
|
|
||||||
<script src="../hexstrbase64/main_browser.js"></script>
|
|
||||||
<script src="hex.js"></script>
|
|
||||||
<script>
|
|
||||||
testStart();
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
|
@ -1,56 +0,0 @@
|
||||||
function nameObj(n, v) {
|
|
||||||
return {name:n, value:v};
|
|
||||||
}
|
|
||||||
|
|
||||||
function testStart() {
|
|
||||||
document.write('<meta charset="UTF-8">');
|
|
||||||
document.write('<title>hexstrbase64 hex test</title>');
|
|
||||||
console.log("TESTING STARTED");
|
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
document.write('<h1>' + enccases[i].name + '</h1>');
|
|
||||||
console.log("SWITCH " + enccases[i].name);
|
|
||||||
for (var j = 0; j < 2; j++) {
|
|
||||||
document.write('<h2>' + enccases[i].value[j].name + '</h2>');
|
|
||||||
console.log("CASE " + enccases[i].value[j].name);
|
|
||||||
console.log("MUST BE: " + enccases[i].value[j].value);
|
|
||||||
console.log("IS : " + hexstrbase64.strtohex(enccases[i].value[j].name));
|
|
||||||
if (hexstrbase64.strtohex(enccases[i].value[j].name) == enccases[i].value[j].value) {
|
|
||||||
document.write('<p><img src="../ok.png"></img>Equals</p>');
|
|
||||||
console.log("EQUALS");
|
|
||||||
} else {
|
|
||||||
document.write('<p><img src="../fail.png"></img>Not Equals</p>');
|
|
||||||
console.log("NOT EQUALS");
|
|
||||||
}
|
|
||||||
console.log("CASE " + enccases[i].value[j].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("SWITCH " + enccases[i].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("TESTING ENDED");
|
|
||||||
}
|
|
||||||
|
|
||||||
var enccases = [
|
|
||||||
nameObj('Ascii', [
|
|
||||||
nameObj('Hello world!', '00480065006c006c006f00200077006f0072006c00640021'),
|
|
||||||
nameObj('Lorem ipsum', '004c006f00720065006d00200069007000730075006d')
|
|
||||||
]),
|
|
||||||
nameObj('Ascii More Than 64 Bytes', [
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum fermentum ac nisl a sollicitudin. Cras interdum dui turpis, non scelerisque.',
|
|
||||||
'004c006f00720065006d00200069007000730075006d00200064006f006c006f0072002000730069007400200061006d00650074002C00200063006f006e00730065006300740065007400750072002000610064006900700069007300630069006e006700200065006c00690074002e00200056006500730074006900620075006c0075006d0020006600650072006d0065006e00740075006d0020006100630020006e00690073006c0020006100200073006f006c006c0069006300690074007500640069006e002e0020004300720061007300200069006e00740065007200640075006d00200064007500690020007400750072007000690073002C0020006e006f006e0020007300630065006c0065007200690073007100750065002e'
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dapibus volutpat ligula at pulvinar. Etiam consequat mi fringilla facilisis eleifend.',
|
|
||||||
'004c006f00720065006d00200069007000730075006d00200064006f006c006f0072002000730069007400200061006d00650074002C00200063006f006e00730065006300740065007400750072002000610064006900700069007300630069006e006700200065006c00690074002e002000500068006100730065006c006c007500730020006400610070006900620075007300200076006f006c007500740070006100740020006c006900670075006c0061002000610074002000700075006c00760069006e00610072002e00200045007400690061006d00200063006f006e0073006500710075006100740020006d00690020006600720069006e00670069006c006c006100200066006100630069006c006900730069007300200065006c0065006900660065006e0064002e'
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
nameObj('Unicode UTF8', [
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器',
|
|
||||||
'0044006f007200690061006e0054006500630068002000480065007800200053007400720069006e006700200042006100730065003600348F6C63625668'
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器,用于由DorianTech提供的Node.js',
|
|
||||||
'0044006f007200690061006e0054006500630068002000480065007800200053007400720069006e006700200042006100730065003600348F6C63625668FF0C75284E8E75310044006f007200690061006e005400650063006863D04F9B7684004e006f00640065002e006a0073'
|
|
||||||
)
|
|
||||||
])
|
|
||||||
];
|
|
|
@ -1,16 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>hexstrbase64 test</title>
|
|
||||||
<style>
|
|
||||||
iframe {
|
|
||||||
width: 200px;
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<iframe src="base64.html"></iframe>
|
|
||||||
<iframe src="hex.html"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
10
index.html
10
index.html
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SVR.JS 3.4.30</title>
|
<title>SVR.JS 3.4.32</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<style>
|
<style>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Welcome to SVR.JS 3.4.30</h1>
|
<h1>Welcome to SVR.JS 3.4.32</h1>
|
||||||
<br/>
|
<br/>
|
||||||
<img src="/logo.png" style="width: 256px;" />
|
<img src="/logo.png" style="width: 256px;" />
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -119,11 +119,13 @@
|
||||||
</div>
|
</div>
|
||||||
<p>Changes:</p>
|
<p>Changes:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Mitigated security vulnerability: SVR.JS mods and server-side JavaScript not using href or uobject.pathname in some path checks are no longer vulnerable to access control bypass (from SVR.JS configuration).</li>
|
<li>Added "svrmodpack" deprecation warning.</li>
|
||||||
|
<li>Removed unmaintained primitive analytics mod.</li>
|
||||||
|
<li>Removed unmaintained and undocumented hexstrbase64 library.</li>
|
||||||
|
<li>Added TypeError workaround for Bun 1.0.0</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>Bugs:</p>
|
<p>Bugs:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Some very old mods requiring hexstrbase64 will fail to load.</li>
|
|
||||||
<li>On first load server-side JavaScript will fail to load when SVR.JS is running on Bun.</li>
|
<li>On first load server-side JavaScript will fail to load when SVR.JS is running on Bun.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 243 B |
|
@ -1,124 +0,0 @@
|
||||||
//Base64.js for hexstrbase64 library for Node.js
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2012 Miles Shang <mail@mshang.ca>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included
|
|
||||||
* in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Usage:
|
|
||||||
* Set your settings:
|
|
||||||
* base64.settings.char62 = "-";
|
|
||||||
* base64.settings.char63 = "_";
|
|
||||||
* etc.
|
|
||||||
*
|
|
||||||
* Then:
|
|
||||||
* base64.encode(str) takes a string and returns the base64 encoding of it.
|
|
||||||
* base64.decode(str) does the reverse.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* Add a "padding_mandatory" flag to check for bad padding in the decoder.
|
|
||||||
* Add test cases that throw errors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var base64 = new Object();
|
|
||||||
|
|
||||||
base64.settings = { // defaults
|
|
||||||
"char62" : "+",
|
|
||||||
"char63" : "/",
|
|
||||||
"pad" : "=",
|
|
||||||
"ascii" : false
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Settings:
|
|
||||||
* If "pad" is not null or undefined, then it will be used for encoding.
|
|
||||||
*
|
|
||||||
* If "ascii" is set to true, then the encoder
|
|
||||||
* will assume that plaintext is in 8-bit chars (the standard).
|
|
||||||
* In this case, for every 3 chars in plaintext, you get 4 chars of base64.
|
|
||||||
* Any non-8-bit chars will cause an error.
|
|
||||||
* Otherwise, assume that all plaintext can be in the full range
|
|
||||||
* of Javascript chars, i.e. 16 bits. Get 8 chars of base64 for 3 chars
|
|
||||||
* of plaintext. Any possible JS string can be encoded.
|
|
||||||
*/
|
|
||||||
|
|
||||||
base64.encode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
var c_num = str.charCodeAt(i);
|
|
||||||
if (this.settings.ascii)
|
|
||||||
if (c_num >= 256)
|
|
||||||
throw "Not an 8-bit char.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < (this.settings.ascii ? 8 : 16))
|
|
||||||
c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= 6) {
|
|
||||||
var sextet = buf.slice(0, 6);
|
|
||||||
buf = buf.slice(6);
|
|
||||||
output += this.char_set.charAt(parseInt(sextet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf) { // not empty
|
|
||||||
while (buf.length < 6) buf += "0";
|
|
||||||
output += this.char_set.charAt(parseInt(buf, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.settings.pad)
|
|
||||||
while (output.length % (this.settings.ascii ? 4 : 8) != 0)
|
|
||||||
output += this.settings.pad;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
base64.decode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
var bits = (this.settings.ascii ? 8 : 16);
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
if (str[i] == this.settings.pad) break;
|
|
||||||
var c_num = this.char_set.indexOf(str.charAt(i));
|
|
||||||
if (c_num == -1) throw "Not base64.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < 6) c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= bits) {
|
|
||||||
var octet = buf.slice(0, bits);
|
|
||||||
buf = buf.slice(bits);
|
|
||||||
output += String.fromCharCode(parseInt(octet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
module.exports = base64;
|
|
|
@ -1,123 +0,0 @@
|
||||||
//Base64.js for hexstrbase64 library for browser
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2012 Miles Shang <mail@mshang.ca>
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
* a copy of this software and associated documentation files (the
|
|
||||||
* "Software"), to deal in the Software without restriction, including
|
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
* permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
* the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included
|
|
||||||
* in all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
||||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
||||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
||||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
||||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Usage:
|
|
||||||
* Set your settings:
|
|
||||||
* base64.settings.char62 = "-";
|
|
||||||
* base64.settings.char63 = "_";
|
|
||||||
* etc.
|
|
||||||
*
|
|
||||||
* Then:
|
|
||||||
* base64.encode(str) takes a string and returns the base64 encoding of it.
|
|
||||||
* base64.decode(str) does the reverse.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO:
|
|
||||||
* Add a "padding_mandatory" flag to check for bad padding in the decoder.
|
|
||||||
* Add test cases that throw errors.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var base64 = new Object();
|
|
||||||
|
|
||||||
base64.settings = { // defaults
|
|
||||||
"char62" : "+",
|
|
||||||
"char63" : "/",
|
|
||||||
"pad" : "=",
|
|
||||||
"ascii" : false
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Settings:
|
|
||||||
* If "pad" is not null or undefined, then it will be used for encoding.
|
|
||||||
*
|
|
||||||
* If "ascii" is set to true, then the encoder
|
|
||||||
* will assume that plaintext is in 8-bit chars (the standard).
|
|
||||||
* In this case, for every 3 chars in plaintext, you get 4 chars of base64.
|
|
||||||
* Any non-8-bit chars will cause an error.
|
|
||||||
* Otherwise, assume that all plaintext can be in the full range
|
|
||||||
* of Javascript chars, i.e. 16 bits. Get 8 chars of base64 for 3 chars
|
|
||||||
* of plaintext. Any possible JS string can be encoded.
|
|
||||||
*/
|
|
||||||
|
|
||||||
base64.encode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
var c_num = str.charCodeAt(i);
|
|
||||||
if (this.settings.ascii)
|
|
||||||
if (c_num >= 256)
|
|
||||||
throw "Not an 8-bit char.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < (this.settings.ascii ? 8 : 16))
|
|
||||||
c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= 6) {
|
|
||||||
var sextet = buf.slice(0, 6);
|
|
||||||
buf = buf.slice(6);
|
|
||||||
output += this.char_set.charAt(parseInt(sextet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf) { // not empty
|
|
||||||
while (buf.length < 6) buf += "0";
|
|
||||||
output += this.char_set.charAt(parseInt(buf, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.settings.pad)
|
|
||||||
while (output.length % (this.settings.ascii ? 4 : 8) != 0)
|
|
||||||
output += this.settings.pad;
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
base64.decode = function (str) {
|
|
||||||
this.char_set =
|
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
||||||
+ this.settings.char62 + this.settings.char63;
|
|
||||||
|
|
||||||
var output = ""; // final output
|
|
||||||
var buf = ""; // binary buffer
|
|
||||||
var bits = (this.settings.ascii ? 8 : 16);
|
|
||||||
for (var i = 0; i < str.length; ++i) {
|
|
||||||
if (str[i] == this.settings.pad) break;
|
|
||||||
var c_num = this.char_set.indexOf(str.charAt(i));
|
|
||||||
if (c_num == -1) throw "Not base64.";
|
|
||||||
var c_bin = c_num.toString(2);
|
|
||||||
while (c_bin.length < 6) c_bin = "0" + c_bin;
|
|
||||||
buf += c_bin;
|
|
||||||
|
|
||||||
while (buf.length >= bits) {
|
|
||||||
var octet = buf.slice(0, bits);
|
|
||||||
buf = buf.slice(bits);
|
|
||||||
output += String.fromCharCode(parseInt(octet, 2));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
|
@ -1,129 +0,0 @@
|
||||||
//Requires base64
|
|
||||||
var base64 = require('./base64.js');
|
|
||||||
var HexStrBase64Buffer = {
|
|
||||||
from: function(s, e) {
|
|
||||||
var type = e;
|
|
||||||
var value = '';
|
|
||||||
if (e == 'base64') {
|
|
||||||
value = base64.decode(s);
|
|
||||||
} else if (e == 'hex') {
|
|
||||||
try {
|
|
||||||
var escaped = "";
|
|
||||||
var hex = "";
|
|
||||||
if(s.length%4 > 0) {
|
|
||||||
for(i=0;i<(4-(s.length%4));i++) {
|
|
||||||
hex += "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hex += s;
|
|
||||||
for(var i = 0;i<hex.length;i += 4) {
|
|
||||||
escaped += new String("%u" + hex.charAt(i) + hex.charAt(i + 1) + hex.charAt(i + 2) + hex.charAt(i + 3)).toString().split("undefined").join("");
|
|
||||||
}
|
|
||||||
value = unescape(escaped).split(unescape("%00")).join("");
|
|
||||||
} catch (ex) {
|
|
||||||
var modex = ex.toString().split('Error: ');
|
|
||||||
modex[0] = '';
|
|
||||||
if (typeof modex == 'object') {
|
|
||||||
throw new Error(
|
|
||||||
'Invaild hex input: ' + s + '. Reason: ' + modex.join('')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new Error('Invaild hex input: ' + s + '. Reason: ' + ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value = Buffer.from(s, 'utf8').toString(e);
|
|
||||||
}
|
|
||||||
function toString(en) {
|
|
||||||
//function toStringE(en,type) {
|
|
||||||
if (en == 'base64') {
|
|
||||||
return base64.encode(value);
|
|
||||||
} else if (en == 'hex') {
|
|
||||||
var result = "";
|
|
||||||
for(var i=0;i<value.length;i++) {
|
|
||||||
var unicode = escape(value.charAt(i));
|
|
||||||
var hex = "";
|
|
||||||
if(value.charAt(i) == "\n") {
|
|
||||||
hex = "000a";
|
|
||||||
} else if(value.charAt(i) == "\r") {
|
|
||||||
hex = "000d";
|
|
||||||
} else if(value.charAt(i) == " ") {
|
|
||||||
hex = "0020";
|
|
||||||
} else if(value.charAt(i) == "\0") {
|
|
||||||
hex = "";
|
|
||||||
} else if(unicode == value.charAt(i)) {
|
|
||||||
var oldhex = value.charCodeAt(i).toString(16);
|
|
||||||
var newhex = "";
|
|
||||||
if(oldhex.length < 4) {
|
|
||||||
for(var j=0;j<4-(oldhex.length%4);j++) {
|
|
||||||
newhex += "0";
|
|
||||||
}
|
|
||||||
newhex += oldhex;
|
|
||||||
} else {
|
|
||||||
newhex = oldhex;
|
|
||||||
}
|
|
||||||
hex = newhex;
|
|
||||||
} else {
|
|
||||||
hex = unicode.split("%u").join("");
|
|
||||||
}
|
|
||||||
if(hex.length == 4 || hex === "") {
|
|
||||||
result += hex;
|
|
||||||
} else if(hex.length > 4) {
|
|
||||||
result += hex.substring(hex.length-5,hex.length-1);
|
|
||||||
} else if(hex.length < 4) {
|
|
||||||
for(var j=0;j<=4-(hex.length%4);j++) {
|
|
||||||
result += "0";
|
|
||||||
}
|
|
||||||
result += hex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.split("undefined").join("").split("%").join("");
|
|
||||||
} else {
|
|
||||||
//return Buffer.from(value, type).toString(en);
|
|
||||||
return Buffer.from(value,"utf8").toString(en);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//}
|
|
||||||
//function toString(en) {
|
|
||||||
//return toStringE(en,type);
|
|
||||||
//}
|
|
||||||
return { type: type, value: value, toString: toString };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var hexstrbase64 = {
|
|
||||||
strtobase64: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('base64');
|
|
||||||
},
|
|
||||||
base64tostr: function(b) {
|
|
||||||
return HexStrBase64Buffer.from(b, 'base64').toString('utf8');
|
|
||||||
},
|
|
||||||
strtohex: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('hex');
|
|
||||||
},
|
|
||||||
hextostr: function(h) {
|
|
||||||
return HexStrBase64Buffer.from(h, 'hex').toString('utf8');
|
|
||||||
},
|
|
||||||
hextobase64: function(h) {
|
|
||||||
return hexstrbase64.strtobase64(hexstrbase64.hextostr(h));
|
|
||||||
},
|
|
||||||
base64tohex: function(b) {
|
|
||||||
return hexstrbase64.strtohex(hexstrbase64.base64tostr(b));
|
|
||||||
},
|
|
||||||
cipher: function() {
|
|
||||||
this.strtobase64 = hexstrbase64.strtobase64;
|
|
||||||
this.base64tostr = hexstrbase64.base64tostr;
|
|
||||||
this.strtohex = hexstrbase64.strtohex;
|
|
||||||
this.hextostr = hexstrbase64.hextostr;
|
|
||||||
this.hextobase64 = hextobase64.hextobase64;
|
|
||||||
this.base64tohex = hextobase64.base64tohex;
|
|
||||||
},
|
|
||||||
native: {
|
|
||||||
btoa: function(b) {
|
|
||||||
return hexstrbase64.strtobase64(b);
|
|
||||||
},
|
|
||||||
atob: function(a) {
|
|
||||||
return hexstrbase64.base64tostr(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
module.exports = hexstrbase64;
|
|
|
@ -1,126 +0,0 @@
|
||||||
//Requires base64_browser.js
|
|
||||||
var HexStrBase64Buffer = {
|
|
||||||
from: function(s, e) {
|
|
||||||
var type = e;
|
|
||||||
var value = '';
|
|
||||||
if (e == 'base64') {
|
|
||||||
value = base64.decode(s);
|
|
||||||
} else if (e == 'hex') {
|
|
||||||
try {
|
|
||||||
var escaped = "";
|
|
||||||
var hex = "";
|
|
||||||
if(s.length%4 > 0) {
|
|
||||||
for(i=0;i<(4-(s.length%4));i++) {
|
|
||||||
hex += "0";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hex += s;
|
|
||||||
for(var i = 0;i<hex.length;i += 4) {
|
|
||||||
escaped += new String("%u" + hex.charAt(i) + hex.charAt(i + 1) + hex.charAt(i + 2) + hex.charAt(i + 3)).toString().split("undefined").join("");
|
|
||||||
}
|
|
||||||
value = unescape(escaped).split(unescape("%00")).join("");
|
|
||||||
} catch (ex) {
|
|
||||||
var modex = ex.toString().split('Error: ');
|
|
||||||
modex[0] = '';
|
|
||||||
if (typeof modex == 'object') {
|
|
||||||
throw new Error(
|
|
||||||
'Invaild hex input: ' + s + '. Reason: ' + modex.join('')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
throw new Error('Invaild hex input: ' + s + '. Reason: ' + ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value = new TextDecoder(e).decode(new TextEncoder('utf8').encode(s));
|
|
||||||
}
|
|
||||||
//function toStringE(en,type) {
|
|
||||||
function toString(en) {
|
|
||||||
if (en == 'base64') {
|
|
||||||
return base64.encode(value);
|
|
||||||
} else if (en == 'hex') {
|
|
||||||
var result = "";
|
|
||||||
for(var i=0;i<value.length;i++) {
|
|
||||||
var unicode = escape(value.charAt(i));
|
|
||||||
var hex = "";
|
|
||||||
if(value.charAt(i) == "\n") {
|
|
||||||
hex = "000a";
|
|
||||||
} else if(value.charAt(i) == "\r") {
|
|
||||||
hex = "000d";
|
|
||||||
} else if(value.charAt(i) == " ") {
|
|
||||||
hex = "0020";
|
|
||||||
} else if(value.charAt(i) == "\0") {
|
|
||||||
hex = "";
|
|
||||||
} else if(unicode == value.charAt(i)) {
|
|
||||||
var oldhex = value.charCodeAt(i).toString(16);
|
|
||||||
var newhex = "";
|
|
||||||
if(oldhex.length < 4) {
|
|
||||||
for(var j=0;j<4-(oldhex.length%4);j++) {
|
|
||||||
newhex += "0";
|
|
||||||
}
|
|
||||||
newhex += oldhex;
|
|
||||||
} else {
|
|
||||||
newhex = oldhex;
|
|
||||||
}
|
|
||||||
hex = newhex;
|
|
||||||
} else {
|
|
||||||
hex = unicode.split("%u").join("");
|
|
||||||
}
|
|
||||||
if(hex.length == 4 || hex === "") {
|
|
||||||
result += hex;
|
|
||||||
} else if(hex.length > 4) {
|
|
||||||
result += hex.substring(hex.length-5,hex.length-1);
|
|
||||||
} else if(hex.length < 4) {
|
|
||||||
for(var j=0;j<=4-(hex.length%4);j++) {
|
|
||||||
result += "0";
|
|
||||||
}
|
|
||||||
result += hex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.split("undefined").join("").split("%").join("");
|
|
||||||
} else {
|
|
||||||
//return new TextDecoder(en).decode(new TextEncoder(type).encode(value));
|
|
||||||
return new TextDecoder(en).decode(new TextEncoder("utf8").encode(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//function toString(en) {
|
|
||||||
//return toStringE(en,type);
|
|
||||||
//}
|
|
||||||
return { type: type, value: value, toString: toString };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var hexstrbase64 = {
|
|
||||||
strtobase64: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('base64');
|
|
||||||
},
|
|
||||||
base64tostr: function(b) {
|
|
||||||
return HexStrBase64Buffer.from(b, 'base64').toString('utf8');
|
|
||||||
},
|
|
||||||
strtohex: function(s) {
|
|
||||||
return HexStrBase64Buffer.from(s, 'utf8').toString('hex');
|
|
||||||
},
|
|
||||||
hextostr: function(h) {
|
|
||||||
return HexStrBase64Buffer.from(h, 'hex').toString('utf8');
|
|
||||||
},
|
|
||||||
hextobase64: function(h) {
|
|
||||||
return hexstrbase64.strtobase64(hexstrbase64.hextostr(h));
|
|
||||||
},
|
|
||||||
base64tohex: function(b) {
|
|
||||||
return hexstrbase64.strtohex(hexstrbase64.base64tostr(b));
|
|
||||||
},
|
|
||||||
cipher: function() {
|
|
||||||
this.strtobase64 = hexstrbase64.strtobase64;
|
|
||||||
this.base64tostr = hexstrbase64.base64tostr;
|
|
||||||
this.strtohex = hexstrbase64.strtohex;
|
|
||||||
this.hextostr = hexstrbase64.hextostr;
|
|
||||||
this.hextobase64 = hextobase64.hextobase64;
|
|
||||||
this.base64tohex = hextobase64.base64tohex;
|
|
||||||
},
|
|
||||||
native: {
|
|
||||||
btoa: function(b) {
|
|
||||||
return hexstrbase64.strtobase64(b);
|
|
||||||
},
|
|
||||||
atob: function(a) {
|
|
||||||
return hexstrbase64.base64tostr(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,11 +0,0 @@
|
||||||
let hexstrbase64 = require("./hexstrbase64/main.js");
|
|
||||||
function decodeBase(b) {
|
|
||||||
return hexstrbase64.native.atob(b);
|
|
||||||
}
|
|
||||||
function encodeStr(s) {
|
|
||||||
return hexstrbase64.native.btoa(s);
|
|
||||||
}
|
|
||||||
var m = Object.create(hexstrbase64);
|
|
||||||
m.decodeBase = decodeBase;
|
|
||||||
m.encodeBase = encodeStr;
|
|
||||||
module.exports = m;
|
|
Binary file not shown.
Before Width: | Height: | Size: 252 B |
|
@ -1,8 +0,0 @@
|
||||||
.code {
|
|
||||||
border-width: 5px;
|
|
||||||
border-color: #BEBEBE;
|
|
||||||
border-style: solid;
|
|
||||||
color:black;
|
|
||||||
background-color: #7F7F7F;
|
|
||||||
font-family: Hack,Consolas,Monaco,monospace;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>HexStrBase64 Readme</title>
|
|
||||||
<link rel="stylesheet" href="readme.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>hexstrbase64</h1>
|
|
||||||
<h2>How to install?</h2>
|
|
||||||
<h3>Node.js</h3>
|
|
||||||
<ol>
|
|
||||||
<li>Download library from <a href="https://repl.it/@DorianNiemiec/Hex-String-Base64-NodeJS-Library.zip" download>here</a>.</li>
|
|
||||||
<li>Modify index.js</li>
|
|
||||||
<li>Write header in program (replace <b>./hexstrbase64</b> with your path to hexstrbase64 library):</li>
|
|
||||||
<div class="code">
|
|
||||||
var hexstrbase64 = require("<b>./hexstrbase64</b>/index.js");<br/>
|
|
||||||
</div>
|
|
||||||
<li>Now hexstrbase64 library added to program!</li>
|
|
||||||
</ol>
|
|
||||||
<h3>Browser Javascript</h3>
|
|
||||||
<ol>
|
|
||||||
<li>Download library from <a href="https://repl.it/@DorianNiemiec/Hex-String-Base64-NodeJS-Library.zip" download>here</a>.</li>
|
|
||||||
<li>Write this code in <head> element (replace <b>hexstrbase64/</b> with your path to hexstrbase64 library):</li>
|
|
||||||
<div class="code">
|
|
||||||
<script src="<b>hexstrbase64/</b>hexstrbase64/base64_browser.js"></script><br/>
|
|
||||||
<script src="<b>hexstrbase64/</b>hexstrbase64/main_browser.js"></script>
|
|
||||||
</div>
|
|
||||||
<li>Now hexstrbase64 library added to HTML!</li>
|
|
||||||
</ol>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>hexstrbase64 base64 test</title>
|
|
||||||
<script src="../hexstrbase64/base64_browser.js"></script>
|
|
||||||
<script src="../hexstrbase64/main_browser.js"></script>
|
|
||||||
<script src="base64.js"></script>
|
|
||||||
<script>
|
|
||||||
testStart();
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
|
@ -1,56 +0,0 @@
|
||||||
function nameObj(n, v) {
|
|
||||||
return {name:n, value:v};
|
|
||||||
}
|
|
||||||
|
|
||||||
function testStart() {
|
|
||||||
document.write('<meta charset="UTF-8">');
|
|
||||||
document.write('<title>hexstrbase64 base64 test</title>');
|
|
||||||
console.log("TESTING STARTED");
|
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
document.write('<h1>' + enccases[i].name + '</h1>');
|
|
||||||
console.log("SWITCH " + enccases[i].name);
|
|
||||||
for (var j = 0; j < 2; j++) {
|
|
||||||
document.write('<h2>' + enccases[i].value[j].name + '</h2>');
|
|
||||||
console.log("CASE " + enccases[i].value[j].name);
|
|
||||||
console.log("MUST BE: " + enccases[i].value[j].value);
|
|
||||||
console.log("IS : " + hexstrbase64.strtobase64(enccases[i].value[j].name));
|
|
||||||
if (hexstrbase64.strtobase64(enccases[i].value[j].name) == enccases[i].value[j].value) {
|
|
||||||
document.write('<p><img src="../ok.png"></img>Equals</p>');
|
|
||||||
console.log("EQUALS");
|
|
||||||
} else {
|
|
||||||
document.write('<p><img src="../fail.png"></img>Not Equals</p>');
|
|
||||||
console.log("NOT EQUALS");
|
|
||||||
}
|
|
||||||
console.log("CASE " + enccases[i].value[j].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("SWITCH " + enccases[i].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("TESTING ENDED");
|
|
||||||
}
|
|
||||||
|
|
||||||
var enccases = [
|
|
||||||
nameObj('Ascii', [
|
|
||||||
nameObj('Hello world!', 'AEgAZQBsAGwAbwAgAHcAbwByAGwAZAAh'),
|
|
||||||
nameObj('Lorem ipsum', 'AEwAbwByAGUAbQAgAGkAcABzAHUAbQ==')
|
|
||||||
]),
|
|
||||||
nameObj('Ascii More Than 64 Bytes', [
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum fermentum ac nisl a sollicitudin. Cras interdum dui turpis, non scelerisque.',
|
|
||||||
'AEwAbwByAGUAbQAgAGkAcABzAHUAbQAgAGQAbwBsAG8AcgAgAHMAaQB0ACAAYQBtAGUAdAAsACAAYwBvAG4AcwBlAGMAdABlAHQAdQByACAAYQBkAGkAcABpAHMAYwBpAG4AZwAgAGUAbABpAHQALgAgAFYAZQBzAHQAaQBiAHUAbAB1AG0AIABmAGUAcgBtAGUAbgB0AHUAbQAgAGEAYwAgAG4AaQBzAGwAIABhACAAcwBvAGwAbABpAGMAaQB0AHUAZABpAG4ALgAgAEMAcgBhAHMAIABpAG4AdABlAHIAZAB1AG0AIABkAHUAaQAgAHQAdQByAHAAaQBzACwAIABuAG8AbgAgAHMAYwBlAGwAZQByAGkAcwBxAHUAZQAu'
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dapibus volutpat ligula at pulvinar. Etiam consequat mi fringilla facilisis eleifend.',
|
|
||||||
'AEwAbwByAGUAbQAgAGkAcABzAHUAbQAgAGQAbwBsAG8AcgAgAHMAaQB0ACAAYQBtAGUAdAAsACAAYwBvAG4AcwBlAGMAdABlAHQAdQByACAAYQBkAGkAcABpAHMAYwBpAG4AZwAgAGUAbABpAHQALgAgAFAAaABhAHMAZQBsAGwAdQBzACAAZABhAHAAaQBiAHUAcwAgAHYAbwBsAHUAdABwAGEAdAAgAGwAaQBnAHUAbABhACAAYQB0ACAAcAB1AGwAdgBpAG4AYQByAC4AIABFAHQAaQBhAG0AIABjAG8AbgBzAGUAcQB1AGEAdAAgAG0AaQAgAGYAcgBpAG4AZwBpAGwAbABhACAAZgBhAGMAaQBsAGkAcwBpAHMAIABlAGwAZQBpAGYAZQBuAGQALg=='
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
nameObj('Unicode UTF8', [
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器',
|
|
||||||
'AEQAbwByAGkAYQBuAFQAZQBjAGgAIABIAGUAeAAgAFMAdAByAGkAbgBnACAAQgBhAHMAZQA2ADSPbGNiVmg====='
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器,用于由DorianTech提供的Node.js',
|
|
||||||
'AEQAbwByAGkAYQBuAFQAZQBjAGgAIABIAGUAeAAgAFMAdAByAGkAbgBnACAAQgBhAHMAZQA2ADSPbGNiVmj/DHUoTo51MQBEAG8AcgBpAGEAbgBUAGUAYwBoY9BPm3aEAE4AbwBkAGUALgBqAHM====='
|
|
||||||
)
|
|
||||||
])
|
|
||||||
];
|
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>hexstrbase64 hex test</title>
|
|
||||||
<script src="../hexstrbase64/base64_browser.js"></script>
|
|
||||||
<script src="../hexstrbase64/main_browser.js"></script>
|
|
||||||
<script src="hex.js"></script>
|
|
||||||
<script>
|
|
||||||
testStart();
|
|
||||||
</script>
|
|
||||||
</head>
|
|
||||||
</html>
|
|
|
@ -1,56 +0,0 @@
|
||||||
function nameObj(n, v) {
|
|
||||||
return {name:n, value:v};
|
|
||||||
}
|
|
||||||
|
|
||||||
function testStart() {
|
|
||||||
document.write('<meta charset="UTF-8">');
|
|
||||||
document.write('<title>hexstrbase64 hex test</title>');
|
|
||||||
console.log("TESTING STARTED");
|
|
||||||
for (var i = 0; i < 3; i++) {
|
|
||||||
document.write('<h1>' + enccases[i].name + '</h1>');
|
|
||||||
console.log("SWITCH " + enccases[i].name);
|
|
||||||
for (var j = 0; j < 2; j++) {
|
|
||||||
document.write('<h2>' + enccases[i].value[j].name + '</h2>');
|
|
||||||
console.log("CASE " + enccases[i].value[j].name);
|
|
||||||
console.log("MUST BE: " + enccases[i].value[j].value);
|
|
||||||
console.log("IS : " + hexstrbase64.strtohex(enccases[i].value[j].name));
|
|
||||||
if (hexstrbase64.strtohex(enccases[i].value[j].name) == enccases[i].value[j].value) {
|
|
||||||
document.write('<p><img src="../ok.png"></img>Equals</p>');
|
|
||||||
console.log("EQUALS");
|
|
||||||
} else {
|
|
||||||
document.write('<p><img src="../fail.png"></img>Not Equals</p>');
|
|
||||||
console.log("NOT EQUALS");
|
|
||||||
}
|
|
||||||
console.log("CASE " + enccases[i].value[j].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("SWITCH " + enccases[i].name + " ENDED");
|
|
||||||
}
|
|
||||||
console.log("TESTING ENDED");
|
|
||||||
}
|
|
||||||
|
|
||||||
var enccases = [
|
|
||||||
nameObj('Ascii', [
|
|
||||||
nameObj('Hello world!', '00480065006c006c006f00200077006f0072006c00640021'),
|
|
||||||
nameObj('Lorem ipsum', '004c006f00720065006d00200069007000730075006d')
|
|
||||||
]),
|
|
||||||
nameObj('Ascii More Than 64 Bytes', [
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum fermentum ac nisl a sollicitudin. Cras interdum dui turpis, non scelerisque.',
|
|
||||||
'004c006f00720065006d00200069007000730075006d00200064006f006c006f0072002000730069007400200061006d00650074002C00200063006f006e00730065006300740065007400750072002000610064006900700069007300630069006e006700200065006c00690074002e00200056006500730074006900620075006c0075006d0020006600650072006d0065006e00740075006d0020006100630020006e00690073006c0020006100200073006f006c006c0069006300690074007500640069006e002e0020004300720061007300200069006e00740065007200640075006d00200064007500690020007400750072007000690073002C0020006e006f006e0020007300630065006c0065007200690073007100750065002e'
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus dapibus volutpat ligula at pulvinar. Etiam consequat mi fringilla facilisis eleifend.',
|
|
||||||
'004c006f00720065006d00200069007000730075006d00200064006f006c006f0072002000730069007400200061006d00650074002C00200063006f006e00730065006300740065007400750072002000610064006900700069007300630069006e006700200065006c00690074002e002000500068006100730065006c006c007500730020006400610070006900620075007300200076006f006c007500740070006100740020006c006900670075006c0061002000610074002000700075006c00760069006e00610072002e00200045007400690061006d00200063006f006e0073006500710075006100740020006d00690020006600720069006e00670069006c006c006100200066006100630069006c006900730069007300200065006c0065006900660065006e0064002e'
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
nameObj('Unicode UTF8', [
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器',
|
|
||||||
'0044006f007200690061006e0054006500630068002000480065007800200053007400720069006e006700200042006100730065003600348F6C63625668'
|
|
||||||
),
|
|
||||||
nameObj(
|
|
||||||
'DorianTech Hex String Base64转换器,用于由DorianTech提供的Node.js',
|
|
||||||
'0044006f007200690061006e0054006500630068002000480065007800200053007400720069006e006700200042006100730065003600348F6C63625668FF0C75284E8E75310044006f007200690061006e005400650063006863D04F9B7684004e006f00640065002e006a0073'
|
|
||||||
)
|
|
||||||
])
|
|
||||||
];
|
|
|
@ -1,16 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>hexstrbase64 test</title>
|
|
||||||
<style>
|
|
||||||
iframe {
|
|
||||||
width: 200px;
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<iframe src="base64.html"></iframe>
|
|
||||||
<iframe src="hex.html"></iframe>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SVR.JS 3.4.31 Licenses</title>
|
<title>SVR.JS 3.4.32 Licenses</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<style>
|
<style>
|
||||||
|
@ -12,8 +12,8 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>SVR.JS 3.4.31 Licenses</h1>
|
<h1>SVR.JS 3.4.32 Licenses</h1>
|
||||||
<h2>SVR.JS 3.4.31</h2>
|
<h2>SVR.JS 3.4.32</h2>
|
||||||
<div style="display: inline-block; text-align: left; border-width: 2px; border-style: solid; border-color: gray; padding: 8px;">
|
<div style="display: inline-block; text-align: left; border-width: 2px; border-style: solid; border-color: gray; padding: 8px;">
|
||||||
MIT License<br/>
|
MIT License<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br/>
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br/>
|
||||||
SOFTWARE.<br/>
|
SOFTWARE.<br/>
|
||||||
</div>
|
</div>
|
||||||
<h2>Packages used by SVR.JS 3.4.31 and utilities</h2>
|
<h2>Packages used by SVR.JS 3.4.32 and utilities</h2>
|
||||||
<div style="width: 100%; background-color: #ccc; border: 1px solid green; text-align: left; margin: 10px 0;">
|
<div style="width: 100%; background-color: #ccc; border: 1px solid green; text-align: left; margin: 10px 0;">
|
||||||
<div style="float: right;">License: MIT</div>
|
<div style="float: right;">License: MIT</div>
|
||||||
<div style="font-size: 20px;">
|
<div style="font-size: 20px;">
|
||||||
|
|
Binary file not shown.
46
svr.js
46
svr.js
|
@ -71,7 +71,7 @@ function deleteFolderRecursive(path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var os = require("os");
|
var os = require("os");
|
||||||
var version = "3.4.31";
|
var version = "3.4.32";
|
||||||
var singlethreaded = false;
|
var singlethreaded = false;
|
||||||
|
|
||||||
if (process.versions) process.versions.svrjs = version; //Inject SVR.JS into process.versions
|
if (process.versions) process.versions.svrjs = version; //Inject SVR.JS into process.versions
|
||||||
|
@ -214,28 +214,30 @@ if (!singlethreaded) {
|
||||||
function checkSendImplementation(worker) {
|
function checkSendImplementation(worker) {
|
||||||
var sendImplemented = true;
|
var sendImplemented = true;
|
||||||
|
|
||||||
if (!worker.send) {
|
if (!(process.versions && process.versions.bun && process.versions.bun[0] != "0")) {
|
||||||
sendImplemented = false;
|
if (!worker.send) {
|
||||||
}
|
|
||||||
|
|
||||||
oldLog = console.log;
|
|
||||||
console.log = function(a,b,c,d,e,f) {
|
|
||||||
if(a == "ChildProcess.prototype.send() - Sorry! Not implemented yet") {
|
|
||||||
throw new Error("NOT IMPLEMENTED");
|
|
||||||
} else {
|
|
||||||
oldLog(a,b,c,d,e,f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
worker.send(undefined);
|
|
||||||
} catch (err) {
|
|
||||||
if (err.message === "NOT IMPLEMENTED") {
|
|
||||||
sendImplemented = false;
|
sendImplemented = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
console.log = oldLog;
|
oldLog = console.log;
|
||||||
|
console.log = function(a,b,c,d,e,f) {
|
||||||
|
if(a == "ChildProcess.prototype.send() - Sorry! Not implemented yet") {
|
||||||
|
throw new Error("NOT IMPLEMENTED");
|
||||||
|
} else {
|
||||||
|
oldLog(a,b,c,d,e,f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
worker.send(undefined);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.message === "NOT IMPLEMENTED") {
|
||||||
|
sendImplemented = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log = oldLog;
|
||||||
|
}
|
||||||
|
|
||||||
return sendImplemented;
|
return sendImplemented;
|
||||||
}
|
}
|
||||||
|
@ -1242,6 +1244,8 @@ process.exit = function (code) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var svrmodpackUsed = false;
|
||||||
|
|
||||||
if (!disableMods) {
|
if (!disableMods) {
|
||||||
var modloaderFolderName = "modloader";
|
var modloaderFolderName = "modloader";
|
||||||
if (cluster.isPrimary === false) {
|
if (cluster.isPrimary === false) {
|
||||||
|
@ -1284,6 +1288,7 @@ if (!disableMods) {
|
||||||
} else {
|
} else {
|
||||||
if (svrmodpack._errored) throw svrmodpack._errored;
|
if (svrmodpack._errored) throw svrmodpack._errored;
|
||||||
svrmodpack.unpack(modFile, __dirname + "/temp/" + modloaderFolderName + "/" + modFiles[i]);
|
svrmodpack.unpack(modFile, __dirname + "/temp/" + modloaderFolderName + "/" + modFiles[i]);
|
||||||
|
svrmodpackUsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extract();
|
extract();
|
||||||
|
@ -4329,6 +4334,7 @@ function start(init) {
|
||||||
if (version.indexOf("Nightly-") === 0) serverconsole.locwarnmessage("This version is only for test purposes and may be unstable.");
|
if (version.indexOf("Nightly-") === 0) serverconsole.locwarnmessage("This version is only for test purposes and may be unstable.");
|
||||||
if (vnum <= 57 && JSON.stringify(rewriteMap) != "[]") serverconsole.locwarnmessage("Some URL rewriting regexes will not work in Node.JS 8.x and earlier.");
|
if (vnum <= 57 && JSON.stringify(rewriteMap) != "[]") serverconsole.locwarnmessage("Some URL rewriting regexes will not work in Node.JS 8.x and earlier.");
|
||||||
if (http2.__disabled__ !== undefined) serverconsole.locwarnmessage("HTTP/2 isn't supported by your Node.JS version!");
|
if (http2.__disabled__ !== undefined) serverconsole.locwarnmessage("HTTP/2 isn't supported by your Node.JS version!");
|
||||||
|
if (svrmodpackUsed) serverconsole.locwarnmessage("The \"svrmodpack\" library is deprecated. Mods using svrmodpack format may not work in future SVR.JS versions.");
|
||||||
if (process.isBun) serverconsole.locwarnmessage("Bun support is experimental.");
|
if (process.isBun) serverconsole.locwarnmessage("Bun support is experimental.");
|
||||||
if (cluster.isPrimary === undefined) serverconsole.locwarnmessage("You're running SVR.JS on single thread. Reliability may suffer.");
|
if (cluster.isPrimary === undefined) serverconsole.locwarnmessage("You're running SVR.JS on single thread. Reliability may suffer.");
|
||||||
if (crypto.__disabled__ !== undefined) serverconsole.locwarnmessage("Your Node.JS version doesn't have crypto support!");
|
if (crypto.__disabled__ !== undefined) serverconsole.locwarnmessage("Your Node.JS version doesn't have crypto support!");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>SVR.JS 3.4.31 Tests</title>
|
<title>SVR.JS 3.4.32 Tests</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<style>
|
<style>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>SVR.JS 3.4.31 Tests</h1>
|
<h1>SVR.JS 3.4.32 Tests</h1>
|
||||||
<h2>Directory</h2>
|
<h2>Directory</h2>
|
||||||
<iframe src="/testdir" width="50%" height="300px"></iframe>
|
<iframe src="/testdir" width="50%" height="300px"></iframe>
|
||||||
<h2>Directory (with query)</h2>
|
<h2>Directory (with query)</h2>
|
||||||
|
|
Reference in a new issue