Тема: AHK: Текст в Base64
Не нашёл способа преобразования текста (переменной с текстом) в Base64 и обратно, без создания файла.
Так понимаю, что нужно как-то"перевести" переменную с текстом в бинарный вид, а при декодировании прочитать как UTF-16?
Base64ToBin(Base64) {
DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), UInt,&Base64
, UInt,StrLen(Base64), UInt,1, UInt,0, UIntP,Bytes, Int,0, Int,0, "CDECL Int")
VarSetCapacity(Bin, Req := Bytes * (A_IsUnicode ? 2 : 1))
DllCall("Crypt32.dll\CryptStringToBinary" (A_IsUnicode ? "W" : "A"), UInt,&Base64
, UInt,StrLen(Base64), UInt,1, Str,Bin, UIntP,Req, Int,0, Int,0, "CDECL Int")
Return Bin
}
BinToBase64(Bin) {
DllCall("Crypt32.dll\CryptBinaryToString" (A_IsUnicode ? "W" : "A")
, UInt,&Bin, UInt,Size, UInt,1, UInt,0, UIntP,TChars, "CDECL Int")
VarSetCapacity(Base64, Req := TChars * (A_IsUnicode ? 2 : 1))
DllCall("Crypt32.dll\CryptBinaryToString" (A_IsUnicode ? "W" : "A")
, UInt,&Bin, UInt,Size, UInt,1, Str,Base64, UIntP,Req, "CDECL Int")
Return Base64
}
Win10x64 AhkSpy, Hotkey, ClockGui