38 lines
2.4 KiB
JavaScript
38 lines
2.4 KiB
JavaScript
|
const tool = require("./tool")
|
||
|
|
||
|
const str1 = "722 黄谦 cheney";
|
||
|
const str2 = "MIIBygYJKoZIhvcNAQcDoIIBuzCCAbcCAQAxggFLMIIBRwIBADAvMCMxCzAJBgNVBAYTAmNuMRQwEgYDVQQKEwtQQkMgVEVTVCBDQQIIE6NthajbntAwDQYJKoZIhvcNAQEBBQAEggEAfpqiXGzxULaCOJIPqRKFAsk/21WIg+NnrkgP/18OxSr68vnpLXKB2aDsyntX9RkwDVc/VwD7nrAq9l0xZPndrYQS2h8ayFfFUan7L5MtOvxS4Pt5+o84DE00+3axfkAr2v7I79tWFmAc0sipn+nQcJzoy0owknfG41hMauMrPI9jdtb1ZcUWLH0bMQ3VeYJJi8RSFYqirpc+RM3sOqwIvBthDcMdnH4XoUx4FKSdnpUd5wHd8Q1cEleVA1PAuEtim2ivjJ8450Y/08pURDOWcmabvX/f4mMp9437uigaC4qShRilyX3/Dt3xhdjq6ImKGxwLUqAaIM6DtHub08S0OTBjBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECP6Q/L2a03NMgECXtfqTp+J8JJGL9mNjf51jMe+C4E02q6UQtImLqmvnBEXCnkDLKOBIvOO7ADrlRDN73cma0865Qp1QXP2PT7ez"
|
||
|
const hex2 = "308201ca06092a864886f70d010703a08201bb308201b70201003182014b30820147020100302f3023310b300906035504061302636e31143012060355040a130b5042432054455354204341020813a36d85a8db9ed0300d06092a864886f70d0101010500048201007e9aa25c6cf150b68238920fa9128502c93fdb558883e367ae480fff5f0ec52afaf2f9e92d7281d9a0ecca7b57f519300d573f5700fb9eb02af65d3164f9ddad8412da1f1ac857c551a9fb2f932d3afc52e0fb79fa8f380c4d34fb76b17e402bdafec8efdb5616601cd2c8a99fe9d0709ce8cb4a309277c6e3584c6ae32b3c8f6376d6f565c5162c7d1b310dd57982498bc452158aa2ae973e44cdec3aac08bc1b610dc31d9c7e17a14c7814a49d9e951de701ddf10d5c1257950353c0b84b629b68af8c9f38e7463fd3ca5444339672669bbd7fdfe26329f78dfbba281a0b8a928518a5c97dff0eddf185d8eae8898a1b1c0b52a01a20ce83b47b9bd3c4b439306306092a864886f70d010701301406082a864886f70d03070408fe90fcbd9ad3734c804097b5fa93a7e27c24918bf663637f9d6331ef82e04d36aba510b4898baa6be70445c29e40cb28e048bce3bb003ae544337bddc99ad3ceb9429d505cfd8f4fb7b3"
|
||
|
const str3 = "722 cheney";
|
||
|
|
||
|
|
||
|
const ret2 = tool.base64ToHex( str2 )
|
||
|
console.log("hex=" + ret2)
|
||
|
console.assert( ret2 === hex2, "base64ToHex 转换失败" );
|
||
|
|
||
|
const ret22 = tool.hexToBase64( ret2 )
|
||
|
console.assert( str2 === ret22, "base64 hex 转换失败" );
|
||
|
|
||
|
|
||
|
const base64 = tool.utf8ToBase64(str1)
|
||
|
const ret3 = tool.base64ToHex( base64 )
|
||
|
console.log("base64ToHex hex=" + ret3 )
|
||
|
const ret32 = tool.hexToBase64( ret3 )
|
||
|
console.assert( ret32 === base64, "base64 hex 中文 转换失败" );
|
||
|
|
||
|
|
||
|
var ret11 = tool.utf8ToBase64(str1)
|
||
|
console.log("hex=" + ret11 )
|
||
|
|
||
|
var ret12 = tool.base64ToUtf8(ret11)
|
||
|
console.log("ret12=" + ret12)
|
||
|
console.assert( str1 === ret12, "base64 String 中文转换失败" );
|
||
|
|
||
|
|
||
|
var ret4 = tool.utf8ToHex(str1);
|
||
|
var ret41 = tool.hexToUtf8(ret4);
|
||
|
console.assert( str1 === ret41, "hex String 中文转换失败" );
|
||
|
|
||
|
|
||
|
|