1 (изменено: Malcev, 2018-09-07 21:24:53)

Тема: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Почему объект file его понимает, а ADODB.Stream нет?
Хотя если декодировать через MSXML2.DOMDocument, то ADODB.Stream понимает.

var:= "PHQ+0J/RgNC40LzQtdGAINC00LXQutC+0LTQuNGA0L7QstCw0L3QuNGPIGJhc2U2NDwvdD4="

Bytes := Base64Dec(BIN, var)

oFile := FileOpen("oFile", "w")
oFile.RawWrite(BIN, Bytes)
oFile.Close()

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1 ; adTypeBinary
oADO.Open
oADO.Write(BIN)
oADO.SaveToFile("oADO")
oADO.Close

objXML := ComObjCreate("MSXML2.DOMDocument")
objDocElem := objXML.createElement("tmp")
objDocElem.DataType := "bin.base64"
objDocElem.text := var
writeBytes := objDocElem.NodeTypedValue
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1 ; adTypeBinary
oADO.Open
oADO.Write(writeBytes)
oADO.SaveToFile("oADOXML")
oADO.Close



Base64dec(ByRef OutData, ByRef InData)
{
   DllCall("Crypt32.dll\CryptStringToBinary", Ptr, &InData, UInt, StrLen(InData), UInt,1, UInt,0, UIntP, Bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(OutData, Bytes)
   DllCall("Crypt32.dll\CryptStringToBinary",  Ptr, &InData, UInt, StrLen(InData), UInt,1, Str, OutData, UIntP, Bytes, UIntP, 0, UIntP, 0)
   Return Bytes
}

2

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Malcev пишет:
oADO.Write(BIN)

А что ты ему скормить пытаешься в данном случае?

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

3

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

teadrinker, я так понимаю, функция декодирует Base64 строку и результат помещает в переменную ByRef BIN.

4

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Неправильно понимаете, результат не в переменной, переменная используется в качестве указателя.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

5

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

teadrinker пишет:

А что ты ему скормить пытаешься в данном случае?

utf-8 интерпретированный как utf-16?
А как из указателя записать в переменную двоичные данные?

6 (изменено: teadrinker, 2018-09-08 08:17:51)

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Смотря, для чего их предполагается использовать. Здесь нам нужны данные в виде Variant. Это в сущности bytearray, который является подвидом SAFEARRAY, упакованный в COM-объект. Так что как-то так:

var := "PHQ+0J/RgNC40LzQtdGAINC00LXQutC+0LTQuNGA0L7QstCw0L3QuNGPIGJhc2U2NDwvdD4="
size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
pData := &outData, i := 0
Loop % size
   arr[i++] := *pData++

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := adTypeBinary := 1
oADO.Open
oADO.Write(arr)
oADO.SaveToFile(A_ScriptDir . "\test.txt", adSaveCreateOverWrite := 2)
oADO.Close

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes) 
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

7

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Спасибо!
Я уже натыкался на подобную функцию, но у меня она не сработала.
Не знаешь почему?

var := "PHQ+0J/RgNC40LzQtdGAINC00LXQutC+0LTQuNGA0L7QstCw0L3QuNGPIGJhc2U2NDwvdD4="
size := StringBase64ToData(var, outData)
arr := ByteArray(&outData, size)



oADO := ComObjCreate("ADODB.Stream")
oADO.Type := adTypeBinary := 1
oADO.Open
oADO.Write(arr)
oADO.SaveToFile(A_ScriptDir . "\test.txt", adSaveCreateOverWrite := 2)
oADO.Close

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes) 
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}


ByteArray(ByRef src, bytes, copy:=false)
{
	ByteArr := ComObjArray(0x11, bytes) ; VT_ARRAY|VT_UI1
	ComObjFlags(ByteArr, -1) ; Remove F_OWNVALUE flag
	NumPut(IsByRef(src) ? &src : src, ComObjValue(ByteArr) + 12 + (A_PtrSize==8 ? 4 : 0))
	return copy ? ByteArr.Clone() : ByteArr
}

https://autohotkey.com/boards/viewtopic.php?t=6967

8

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Не знаю, наверно не совсем правильный механизм создания. Я настолько глубоко тему не знаю. Но вот там ниже lexicos пишет:

If what you need is an array of bytes -- not a mechanism for reading/writing a pre-existing pointer -- it would be more appropriate to just call ComObjArray() and copy the data in.

что я и делаю.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

9

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Ещё вот так можно:

var := "PHQ+0J/RgNC40LzQtdGAINC00LXQutC+0LTQuNGA0L7QstCw0L3QuNGPIGJhc2U2NDwvdD4="
size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, NumGet( ComObjValue(arr) + 8 + A_PtrSize ), Ptr, &outData, Ptr, size)

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := adTypeBinary := 1
oADO.Open
oADO.Write(arr)
oADO.SaveToFile(A_ScriptDir . "\test.txt", adSaveCreateOverWrite := 2)
oADO.Close

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes) 
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

10 (изменено: Malcev, 2018-09-10 15:57:33)

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Так это тоже самое, что и

ByteArray(ByRef src, bytes, copy:=false)
{
	ByteArr := ComObjArray(0x11, bytes) ; VT_ARRAY|VT_UI1
	ComObjFlags(ByteArr, -1) ; Remove F_OWNVALUE flag
	NumPut(IsByRef(src) ? &src : src, ComObjValue(ByteArr) + 12 + (A_PtrSize==8 ? 4 : 0))
	return copy ? ByteArr.Clone() : ByteArr
}

только без

ComObjFlags(ByteArr, -1) ; Remove F_OWNVALUE flag

Ты знаешь для чего Coco этот флаг убирает?

11

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Malcev пишет:

Так это тоже самое

Нет, здесь в струтуре SAFEARRAY заменяется указатель pvData на новый, а я, наоборот, использую указатель, который записался при создании структуры, и копирую по этому адресу свои данные.

Malcev пишет:

Ты знаешь для чего Coco этот флаг убирает?

Вот здесь описано.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

12 (изменено: Malcev, 2018-09-11 23:59:37)

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Теперь новая проблема - как обратно закодировать в base64?
С fileread и с fileopen всё получается - начальный и конечный результаты одинаковые.
С oADO.Read результат другой.
Во что нужно перепаковать полученные "data as a variant" для использования в качестве "pointer to the array of bytes to be converted into a string"?
А с oADO.ReadText() последний символ заменяется на NULL, непонятно почему?

var =
( Join
AQAAAAAAAABkcwAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0da3MaOVL+J9R9u9pzABv8qNJ5y/Hj4jonThlvEj6lMMY2twRYwImdH3+7/ZBG7wET28BmygVmulutVqu71ZJmNH/+X4pfxb34InqiJL6KjhiJseiKgeiLf4t/iKp4JSrwvwSYvmgD/AqwfXFD2N/EhTgW60C1RTS/ij0hxT7QDMQllPgszuHXQEwC+AVwmUCdHcJ8cOrdExtQZ0XswGcbPhtAUQ5opHhLnPn6s2gAfkLXKN2YKN5DDS3xANhjoBqJb3A1Ain2gG4k7qAEck5TSeA6oasJYHU9bbjukD72xDVge1Abc5pGjRKNMr304G8P2scy+HApjoDXmKAnVJopfSjS9UFarPEa/vIlzKdF+QZAO4lKGGJsGc9An5OIlBqO0Ok9Vs6xEmzvmOTtEn4kTqnfBlTDGOzvQ9J+sbxN7V8fkT46wH1C9VwDPMZvQ/Gy6S+Ay5Bk1G2P4Vh+9J520Cs2BuXqgj5aUPqO+mYc0McopHhDmkQ+h4Tvklb8sikq5puvEV9ryOEL2Y7WUZ7OhuITWNEJfB8BlwbAqmKXfB3rDrFYogm/T8Q7gDE9RwWmd3FI3RAHYJ1H8PcO7OicSjBtiJHQ9hHI+A3acUstGanW6gij8eekp1tqL173iee00r4+Q1352twnb2Drxmvdrw2gwZ4w3rBPtbUIi9fXyvNeqfYamITvAbTfxmqIpLq4ZYzfJbwNlSDLgOQagPQ2lQvn6Jcnp8buW1pKt6Mi6rkt0fi8ttRnbE19SntSEpdn6r3XQNMWvyt7uSPfi3lJTXlJA2RtAQ3iz6n1HaoTR1+MIzWQehe8gCXMp5UQfc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4gDrIvX+n9koS6pGnC/ckRb5pBF+956JYjwXcE/uLGVWl8J+ys7k5Rbq3RXG6Te7pWi0FYYn9PqUZWW3T6e9CeUB9tmu5SjMj18u1M0cytEsw6yS8phzJ/SJweaarYd/+5FtSG1uQ00X8EEbC8+ECikk+XVLjQUmY/Wh0vFRrBvf1ojccdQ1MVj3gJGZr9OtK3u5WjnI5T5k72M7VvOpcE8576Sla1XK97FyEoMaO8hyZH1KpA/VdGxV7oqAi0FIWnbGm1a67/ViyInIf/fgnoqFsTdf/gW9PWit
)

size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, NumGet( ComObjValue(arr) + 8 + A_PtrSize ), Ptr, &outData, Ptr, size)
oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1 ; bin
ADO.Mode := 3
oADO.Open
oADO.Write(arr)
oADO.SaveToFile("test", 2)
oADO.Position := 0
aBin := oADO.Read(size)

oADO.Position := 0
oADO.Type := 2 ; text
oADO.Charset := "utf-16" 
aText := oADO.ReadText()
oADO.Close

fileread, b, *c test

file := FileOpen("test", "r", "utf-16")
File.RawRead(c, size)

msgbox % Base64Enc(aBin, size)
msgbox % Base64Enc(aText, size)
msgbox % Base64Enc(b, size)
msgbox % Base64Enc(c, size)




Base64Enc(ByRef Bin, nBytes) { ; By SKAN / 18-Aug-2017
   Local Rqd := 0, B64 ; CRYPT_STRING_BASE64 := 0x1, CRYPT_STRING_NOCRLF := 0x40000000
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr", &Bin ,"UInt", nBytes, "UInt",0x1|0x40000000, "Ptr",0,"UIntP",Rqd )
   VarSetCapacity( B64, Rqd * ( A_Isunicode ? 2 : 1 ), 0 )
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr",&Bin, "UInt",nBytes, "UInt",0x1|0x40000000, "Str",B64, "UIntP",Rqd )
   Return B64
}

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64), UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes)
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64), UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}

13

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Не пойму цель этих манипуляций. У нас ведь уже есть Base64, зачем снова запаковывать?

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

14 (изменено: Malcev, 2018-09-12 03:33:20)

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Цель - распаковать всё, потом разделить на 2 части.
Первую часть - 32 байта оставить как есть, а вторую распаковать с помощью zlib1.dll.
В распакованной части внести изменения, запаковать zlib1.dll объеденить с 32 байтами первой части и всё это запаковать в Base64.
Проще, конечно, обойтись без ADODB.Stream, но хочется разобраться с двумя предыдущими вопросами.

var =
( Join
AQAAAAAAAABkcwAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0da3MaOVL+J9R9u9pzABv8qNJ5y/Hj4jonThlvEj6lMMY2twRYwImdH3+7/ZBG7wET28BmygVmulutVqu71ZJmNH/+X4pfxb34InqiJL6KjhiJseiKgeiLf4t/iKp4JSrwvwSYvmgD/AqwfXFD2N/EhTgW60C1RTS/ij0hxT7QDMQllPgszuHXQEwC+AVwmUCdHcJ8cOrdExtQZ0XswGcbPhtAUQ5opHhLnPn6s2gAfkLXKN2YKN5DDS3xANhjoBqJb3A1Ain2gG4k7qAEck5TSeA6oasJYHU9bbjukD72xDVge1Abc5pGjRKNMr304G8P2scy+HApjoDXmKAnVJopfSjS9UFarPEa/vIlzKdF+QZAO4lKGGJsGc9An5OIlBqO0Ok9Vs6xEmzvmOTtEn4kTqnfBlTDGOzvQ9J+sbxN7V8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XopWuwljx6bgGTfC0AJwTKuJV2ILxj8e3fRZbzEu9myZfWSDuOo3dRi++hRAzc0uOesZictwlu6PnM/6s5xWWs6xbdfyuayebeNv90mUGCxVmn1M91fqPT4lge9m0if461MEq4QZZiXGgs9zcSmwHn26mtuuLllI3qlqePqlOZmN9zfwnQQbKn9z8ZLeJcSxyXipgU0/LeprJhmPOFo/vq2m6aSjqdOoj+ZRID5PW0hxROv8PRVZsJz9fgVjU+acZeQ6a6n4qcJt9QtlQW7xk4XPgc9poC0NRXs7J98cZe1ti3+CBWDM/U6wtTX05BLQrK1dQWwpgW6+i1/Wvipb4dNZEQutWkM8n/T4y1prDfsSy/IZOnhq7e8UF7oAu6FIxSfP/Et5iS+LpHyoT32CEDxxlbXGUeVKedGI4gDrIvX+n9koS6pGnC/ckRb5pBF+956JYjwXcE/uLGVWl8J+ys7k5Rbq3RXG6Te7pWi0FYYn9PqUZWW3T6e9CeUB9tmu5SjMj18u1M0cytEsw6yS8phzJ/SJweaarYd/+5FtSG1uQ00X8EEbC8+ECikk+XVLjQUmY/Wh0vFRrBvf1ojccdQ1MVj3gJGZr9OtK3u5WjnI5T5k72M7VvOpcE8576Sla1XK97FyEoMaO8hyZH1KpA/VdGxV7oqAi0FIWnbGm1a67/ViyInIf/fgnoqFsTdf/gW9PWit
)

size := StringBase64ToData(var, outData)
varsetcapacity(var1, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, &var1, Ptr, &outData, Ptr, 32)
varsetcapacity(var2, size-32)
DllCall("Ntdll\RtlMoveMemory", Ptr, &var2, Ptr, &outData+32, Ptr, size-32)
DllCall("Ntdll\RtlMoveMemory", Ptr, &var1+32, Ptr, &var2, Ptr, size-32)
msgbox % Base64Enc(var1, size)

Base64Enc(ByRef Bin, nBytes) { ; By SKAN / 18-Aug-2017
   Local Rqd := 0, B64 ; CRYPT_STRING_BASE64 := 0x1, CRYPT_STRING_NOCRLF := 0x40000000
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr", &Bin ,"UInt", nBytes, "UInt",0x1|0x40000000, "Ptr",0,"UIntP",Rqd )
   VarSetCapacity( B64, Rqd * ( A_Isunicode ? 2 : 1 ), 0 )
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr",&Bin, "UInt",nBytes, "UInt",0x1|0x40000000, "Str",B64, "UIntP",Rqd )
   Return B64
}

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64), UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes)
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64), UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}

С первым вопросом разобрался:

var =
( Join
AQAAAAAAAABkcwAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0da3MaOVL+J9R9u9pzABv8qNJ5y/Hj4jonThlvEj6lMMY2twRYwImdH3+7/ZBG7wET28BmygVmulutVqu71ZJmNH/+X4pfxb34InqiJL6KjhiJseiKgeiLf4t/iKp4JSrwvwSYvmgD/AqwfXFD2N/EhTgW60C1RTS/ij0hxT7QDMQllPgszuHXQEwC+AVwmUCdHcJ8cOrdExtQZ0XswGcbPhtAUQ5opHhLnPn6s2gAfkLXKN2YKN5DDS3xANhjoBqJb3A1Ain2gG4k7qAEck5TSeA6oasJYHU9bbjukD72xDVge1Abc5pGjRKNMr304G8P2scy+HApjoDXmKAnVJopfSjS9UFarPEa/vIlzKdF+QZAO4lKGGJsGc9An5OIlBqO0Ok9Vs6xEmzvmOTtEn4kTqnfBlTDGOzvQ9J+sbxN7V8fkT46wH1C9VwDPMZvQ/Gy6S+Ay5Bk1G2P4Vh+9J520Cs2BuXqgj5aUPqO+mYc0McopHhDmkQ+h4Tvklb8sikq5puvEV9ryOEL2Y7WUZ7OhuITWNE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if461MEq4QZZiXGgs9zcSmwHn26mtuuLllI3qlqePqlOZmN9zfwnQQbKn9z8ZLeJcSxyXipgU0/LeprJhmPOFo/vq2m6aSjqdOoj+ZRID5PW0hxROv8PRVZsJz9fgVjU+acZeQ6a6n4qcJt9QtlQW7xk4XPgc9poC0NRXs7J98cZe1ti3+CBWDM/U6wtTX05BLQrK1dQWwpgW6+i1/Wvipb4dNZEQutWkM8n/T4y1prDfsSy/IZOnhq7e8UF7oAu6FIxSfP/Et5iS+LpHyoT32CEDxxlbXGUeVKedGI4gDrIvX+n9koS6pGnC/ckRb5pBF+956JYjwXcE/uLGVWl8J+ys7k5Rbq3RXG6Te7pWi0FYYn9PqUZWW3T6e9CeUB9tmu5SjMj18u1M0cytEsw6yS8phzJ/SJweaarYd/+5FtSG1uQ00X8EEbC8+ECikk+XVLjQUmY/Wh0vFRrBvf1ojccdQ1MVj3gJGZr9OtK3u5WjnI5T5k72M7VvOpcE8576Sla1XK97FyEoMaO8hyZH1KpA/VdGxV7oqAi0FIWnbGm1a67/ViyInIf/fgnoqFsTdf/gW9PWit
)

size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, NumGet( ComObjValue(arr) + 8 + A_PtrSize ), Ptr, &outData, Ptr, size)

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := 1 ; bin
ADO.Mode := 3
oADO.Open
oADO.Write(arr)
oADO.Position := 0
aBin := oADO.Read(size)
oADO.Close

varsetcapacity(a, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, &a, Ptr, NumGet( ComObjValue(abin) + 8 + A_PtrSize ), Ptr, size)
msgbox % Base64Enc(a, size)


Base64Enc(ByRef Bin, nBytes) { ; By SKAN / 18-Aug-2017
   Local Rqd := 0, B64 ; CRYPT_STRING_BASE64 := 0x1, CRYPT_STRING_NOCRLF := 0x40000000
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr", &Bin ,"UInt", nBytes, "UInt",0x1|0x40000000, "Ptr",0,"UIntP",Rqd )
   VarSetCapacity( B64, Rqd * ( A_Isunicode ? 2 : 1 ), 0 )
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr",&Bin, "UInt",nBytes, "UInt",0x1|0x40000000, "Str",B64, "UIntP",Rqd )
   Return B64
}

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64), UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes)
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64), UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}

15

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Malcev пишет:

А с oADO.ReadText() последний символ заменяется на NULL, непонятно почему?

У меня не заменяется:

var =
(
EAQgAEEEIABvAEEARABPAC4AUgBlAGEAZABUAGUAeAB0ACgAKQAgAD8EPgRBBDsE
NQQ0BD0EOAQ5BCAAQQQ4BDwEMgQ+BDsEIAA3BDAEPAQ1BD0ETwQ1BEIEQQRPBCAA
PQQwBCAATgBVAEwATAAsACAAPQQ1BD8EPgQ9BE8EQgQ9BD4EIAA/BD4ERwQ1BDwE
QwQ/AA==
)
size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, NumGet( ComObjValue(arr) + 8 + A_PtrSize ), Ptr, &outData, Ptr, size)

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := adTypeBinary := 1
oADO.Open
oADO.Write(arr)
oADO.SaveToFile(A_ScriptDir . "\test.txt", adSaveCreateOverWrite := 2)

oADO.Position := 0
oADO.Type := 2 ; text
; oADO.Charset := "utf-16" 
aText := oADO.ReadText()
oADO.Close

MsgBox, % "|" . aText . "|"

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes) 
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

16

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Это в твоём примере.
А теперь возьми мой:

var =
( Join
AQAAAAAAAABkcwAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0da3MaOVL+J9R9u9pzABv8qNJ5y/Hj4jonThlvEj6lMMY2twRYwImdH3+7/ZBG7wET28BmygVmulutVqu71ZJmNH/+X4pfxb34InqiJL6KjhiJseiKgeiLf4t/iKp4JSrwvwSYvmgD/AqwfXFD2N/EhTgW60C1RTS/ij0hxT7QDMQllPgszuHXQEwC+AVwmUCdHcJ8cOrdExtQZ0XswGcbPhtAUQ5opHhLnPn6s2gAfkLXKN2YKN5DDS3xANhjoBqJb3A1Ain2gG4k7qAEck5TSeA6oasJYHU9bbjukD72xDVge1Abc5pGjRKNMr304G8P2scy+HApjoDXmKAnVJopfSjS9UFarPEa/vIlzKdF+QZAO4lKGGJsGc9An5OIlBqO0Ok9Vs6xEmzvmOTtEn4kTqnfBlTDGOzvQ9J+sbxN7V8fkT46wH1C9VwDPMZvQ/Gy6S+Ay5Bk1G2P4Vh+9J520Cs2BuXqgj5aUPqO+mYc0McopHhDmkQ+h4Tvklb8sikq5puvEV9ryOEL2Y7WUZ7OhuITWNEJfB8BlwbAqmKXfB3rDrFYogm/T8Q7gDE9RwWmd3FI3RAHYJ1H8PcO7OicSjBtiJHQ9hHI+A3acUstGanW6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vq2m6aSjqdOoj+ZRID5PW0hxROv8PRVZsJz9fgVjU+acZeQ6a6n4qcJt9QtlQW7xk4XPgc9poC0NRXs7J98cZe1ti3+CBWDM/U6wtTX05BLQrK1dQWwpgW6+i1/Wvipb4dNZEQutWkM8n/T4y1prDfsSy/IZOnhq7e8UF7oAu6FIxSfP/Et5iS+LpHyoT32CEDxxlbXGUeVKedGI4gDrIvX+n9koS6pGnC/ckRb5pBF+956JYjwXcE/uLGVWl8J+ys7k5Rbq3RXG6Te7pWi0FYYn9PqUZWW3T6e9CeUB9tmu5SjMj18u1M0cytEsw6yS8phzJ/SJweaarYd/+5FtSG1uQ00X8EEbC8+ECikk+XVLjQUmY/Wh0vFRrBvf1ojccdQ1MVj3gJGZr9OtK3u5WjnI5T5k72M7VvOpcE8576Sla1XK97FyEoMaO8hyZH1KpA/VdGxV7oqAi0FIWnbGm1a67/ViyInIf/fgnoqFsTdf/gW9PWit
)
size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, NumGet( ComObjValue(arr) + 8 + A_PtrSize ), Ptr, &outData, Ptr, size)

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := adTypeBinary := 1
oADO.Open
oADO.Write(arr)
oADO.SaveToFile(A_ScriptDir . "\test.txt", adSaveCreateOverWrite := 2)

oADO.Position := 0
oADO.Type := 2 ; text
; oADO.Charset := "utf-16" 
aText := oADO.ReadText()
oADO.Close

msgbox % Base64Enc(aText, size)

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes) 
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}

Base64Enc(ByRef Bin, nBytes) { ; By SKAN / 18-Aug-2017
   Local Rqd := 0, B64 ; CRYPT_STRING_BASE64 := 0x1, CRYPT_STRING_NOCRLF := 0x40000000
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr", &Bin ,"UInt", nBytes, "UInt",0x1|0x40000000, "Ptr",0,"UIntP",Rqd )
   VarSetCapacity( B64, Rqd * ( A_Isunicode ? 2 : 1 ), 0 )
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr",&Bin, "UInt",nBytes, "UInt",0x1|0x40000000, "Str",B64, "UIntP",Rqd )
   Return B64
}

17

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Так это не текст.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

18

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Но эти бинарные данные возвращает нормально:

var =
( Join
AQAAAAAAAAAecwAAAAAAAENvbXByZXNzZWRUaXRsZQB4nO0da1MiuTY/hdrvCqiIVmXZcnzsWOuMU+LOyKcpRFTuZYAFnNH98ffueSSdd4PMKLDTZYH0eeUkOefkJOlO//9/UvwmHsUX0Rcl8VV0xVhMRE8MxUD8Kn4RVbEpKvC/BJiB6AD8BrADcUfYP8WlOBEbQLVLNL+JhpDiAGiG4ho4PosL+DUU0wB+CVKmUGaXMB+dchtiC8qsiD341OGzBRTlgEaKdySZrz+LJuCndI3aTYjiA5TQFk+APQGqsfgGV2PQogF0Y/EAHCg5TSVB6pSupoDV5XTgukvt0RC3gO1DaSxpFjVqNM7apQ9/Dagf6+DDpTgGWROCnhI3U/pQpBuAtljiLfzla5hPi/oNgXYa1TDE2DqeQ3tOI1pqOEJn91g5x0qwvhPSt0f4sTijfhtSCROwv49J+0V+m9q/Pqb26IL0KZVzC/CYvC0ly6a/BCkj0lHXPYZj/dF7OkGv2BjUqwft0QbuB+qbSUAfo5DiLbUkyjkifI9axedNUbHc/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Rwrd32AefW8G3+7z6TEYClu9jbdX6m3+pQEvqlJn+evzxOsEmaUcUwEn+ziUmA5+pw1t149spC889XwHExzRluN/GGTTk4x52TaZ7hdKZ+L+avBzT4/6mumIY9Bup18m03TSafFzqK+mkeB+LxWQ4pjWvnvqyiDfPZbF4xtmdOXUeq8XPGzhjvqF+qC0uLnDV+AnLOgtTQU7e6CfHSc1ZfPGcLs5Bpa9Z5GmwfA3iuL9uklZTEDajeE4DmpXDOOADfK4sfks6xv6s0981GWVImHgt/dMbVOAChZEYczePe8zVJmGT52V2GvsrN0uYZ6T4Rx+p1sKRptKeHJuj5lWdnWj2u9KY3e9oms5SjMjzUu1B3vy9HcwKxt8vjwIPRJv+a6JO6y334UGlGdO1DSJXxw5ApPcgopJPleW8Vtk2f6UOn4EZaN71lE6ThCmnipe8DozNfp2pW9DKscZGAfszepnahZULgTnHc+0q3i8n2snMRgix1mma0+29GHajq2Knce72IQktad8aaW7hu5GHIq8t8a2FDxKvbOyn8AkqdcEA==
)
size := StringBase64ToData(var, outData)
arr := ComObjArray(VT_UI1 := 0x11, size)
DllCall("Ntdll\RtlMoveMemory", Ptr, NumGet( ComObjValue(arr) + 8 + A_PtrSize ), Ptr, &outData, Ptr, size)

oADO := ComObjCreate("ADODB.Stream")
oADO.Type := adTypeBinary := 1
oADO.Open
oADO.Write(arr)
oADO.SaveToFile(A_ScriptDir . "\test.txt", adSaveCreateOverWrite := 2)

oADO.Position := 0
oADO.Type := 2 ; text
; oADO.Charset := "utf-16" 
aText := oADO.ReadText()
oADO.Close

msgbox % Base64Enc(aText, size)

StringBase64ToData(stringBase64, ByRef outData)
{
   static CRYPT := CRYPT_STRING_BASE64 := 1
   
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, UInt, 0, UIntP, bytes, UIntP, 0, UIntP, 0)
   VarSetCapacity(outData, bytes) 
   DllCall("Crypt32\CryptStringToBinary", Ptr, &stringBase64, UInt, StrLen(stringBase64)
                                        , UInt, CRYPT, Str, outData, UIntP, bytes, UIntP, 0, UIntP, 0)
   Return bytes
}

Base64Enc(ByRef Bin, nBytes) { ; By SKAN / 18-Aug-2017
   Local Rqd := 0, B64 ; CRYPT_STRING_BASE64 := 0x1, CRYPT_STRING_NOCRLF := 0x40000000
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr", &Bin ,"UInt", nBytes, "UInt",0x1|0x40000000, "Ptr",0,"UIntP",Rqd )
   VarSetCapacity( B64, Rqd * ( A_Isunicode ? 2 : 1 ), 0 )
   DllCall( "Crypt32.dll\CryptBinaryToString", "Ptr",&Bin, "UInt",nBytes, "UInt",0x1|0x40000000, "Str",B64, "UIntP",Rqd )
   Return B64
}

19

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

В смысле? У меня

https://i.imgur.com/PTndMML.png

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

20

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Если запустить 18 код.

21

Re: AHK: ADODB.Stream не понимает Base64 из CryptStringToBinary

Ну, мало ли отчего может зависеть, может, определённый размер срабатывает.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg