forked from svrjs/svrjs
56 lines
No EOL
3.3 KiB
JavaScript
56 lines
No EOL
3.3 KiB
JavaScript
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'
|
||
)
|
||
])
|
||
]; |