MsgBox % """" b64Encode("The quick brown fox jumps over the lazy dog") """" MsgBox % """" b64Decode("VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==") """" ; base64编码函数 b64Encode加密后,结尾会残留`r`n【20240227修正】 b64Encode(string) { VarSetCapacity(bin, StrPut(string, "UTF-8")) && len := StrPut(string, &bin, "UTF-8") - 1 if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", 0, "uint*", size)) throw Exception("CryptBinaryToString failed", -1) VarSetCapacity(buf, size << 1, 0) if !(DllCall("crypt32\CryptBinaryToString", "ptr", &bin, "uint", len, "uint", 0x1, "ptr", &buf, "uint*", size)) throw Exception("CryptBinaryToString failed", -1) return RTrim(StrGet(&buf), "`r`n") } ; base64解码函数 b64Decode(string) { if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", 0, "uint*", size, "ptr", 0, "ptr", 0)) throw Exception("CryptStringToBinary failed", -1) VarSetCapacity(buf, size, 0) if !(DllCall("crypt32\CryptStringToBinary", "ptr", &string, "uint", 0, "uint", 0x1, "ptr", &buf, "uint*", size, "ptr", 0, "ptr", 0)) throw Exception("CryptStringToBinary failed", -1) return StrGet(&buf, size, "UTF-8") }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)