to encode bytes to base64, use this functions:
Code:
b64Encode( ByRef buf, bufLen )
{
DllCall( "crypt32\CryptBinaryToStringA", "ptr", &buf, "UInt", bufLen, "Uint", 1, "Ptr", 0, "UInt*", outLen )
VarSetCapacity( outBuf, outLen, 0 )
DllCall( "crypt32\CryptBinaryToStringA", "ptr", &buf, "UInt", bufLen, "Uint", 1, "Ptr", &outBuf, "UInt*", outLen )
return strget( &outBuf, outLen, "CP0" )
}
b64Decode( b64str, ByRef outBuf )
{
DllCall( "crypt32\CryptStringToBinaryW", "ptr", &b64str, "UInt", 0, "Uint", 1, "Ptr", 0, "UInt*", outLen, "ptr", 0, "ptr", 0 )
VarSetCapacity( outBuf, outLen, 0 )
DllCall( "crypt32\CryptStringToBinaryW", "ptr", &b64str, "UInt", 0, "Uint", 1, "Ptr", &outBuf, "UInt*", outLen, "ptr", 0, "ptr", 0 )
return outLen
}
for example:
Code:
dataSize := WinClip.Snap( data )
b64string := b64Encode( data, dataSize )
to put data back to clipboard:
Code:
b64Decode( b64string, clipBuf )
WinClip.Restore( clipBuf )