For me the code works as expected if I simulate the PHP-Script by just copy-pasting the result from the first code into the second one:
Code: Select all
str$ = "Some text to test. Some text too."
size = StringByteLength(str$) + 2
*out = AllocateMemory(size)
If AESEncoder(@str$, *out, size, ?key, 256, ?iv, #PB_Cipher_CBC)
Encoded$ = Base64Encoder(*out, size)
Debug Encoded$
Else
Debug "Error"
EndIf
FreeMemory(*out)
DataSection
key:
Data.a $97, $74, $91, $AC, $85, $CF, $CA, $37, $B7, $20, $B2, $FD, $D0, $97, $39, $4F, $BE, $E1, $C7, $C1, $B3, $50, $2C, $6C, $F6, $D4, $9A, $E3, $5A, $E1, $40, $AC
iv:
Data.a $86, $43, $1A, $35, $61, $C9, $8A, $E2, $EF, $7C, $49, $8C, $E6, $F4, $6A, $02
EndDataSection
Result in:
iV7bpLUqiqGhk/1B/ArzzUnr9sqxVHRdkDks95cT+iZ4jRZx6Qj8hZbKny5egUWIr2BCB/YTglNQjZZYBP+jW5EPZtU=
Now put it into the second code:
Code: Select all
s.s = "iV7bpLUqiqGhk/1B/ArzzUnr9sqxVHRdkDks95cT+iZ4jRZx6Qj8hZbKny5egUWIr2BCB/YTglNQjZZYBP+jW5EPZtU="
;*Buffer = ReceiveHTTPMemory("https://arahiotis.sites.sch.gr/PB/update.php")
If #True ;*Buffer
;size = MemorySize(*Buffer)
;str$ = PeekS(*Buffer, size, #PB_UTF8|#PB_ByteLength)
str$ = "iV7bpLUqiqGhk/1B/ArzzUnr9sqxVHRdkDks95cT+iZ4jRZx6Qj8hZbKny5egUWIr2BCB/YTglNQjZZYBP+jW5EPZtU="
Debug str$
size = Len(str$)
Debug "size 1 = " + Str(size)
*buf = AllocateMemory(size)
*out = AllocateMemory(size)
size = Base64Decoder(str$, *buf, size)
Debug "size 2 = " + Str(size)
AESDecoder(*buf,*out,size,?key,256,?iv,#PB_Cipher_CBC)
Debug "Content: " + PeekS(*out)
EndIf
DataSection
key:
Data.a $97, $74, $91, $AC, $85, $CF, $CA, $37, $B7, $20, $B2, $FD, $D0, $97, $39, $4F, $BE, $E1, $C7, $C1, $B3, $50, $2C, $6C, $F6, $D4, $9A, $E3, $5A, $E1, $40, $AC
iv:
Data.a $86, $43, $1A, $35, $61, $C9, $8A, $E2, $EF, $7C, $49, $8C, $E6, $F4, $6A, $02
EndDataSection
Results in:
iV7bpLUqiqGhk/1B/ArzzUnr9sqxVHRdkDks95cT+iZ4jRZx6Qj8hZbKny5egUWIr2BCB/YTglNQjZZYBP+jW5EPZtU=
size 1 = 92
size 2 = 68
Content: Some text to test. Some text too.
But it also works with the PHP output. So the issue seems solved to me. I don't see any errors.
AZJIO wrote: Tue Apr 15, 2025 9:58 pm
You insert the line #PB_Unicode
You read the line #PB_UTF8
Code: Select all
str$ = PeekS(*Buffer, size, #PB_UTF8|#PB_ByteLength)
Base64encoder returns the result in Latin symbols, so you do not need #PB_UTF8 and #PB_Unicode, you need #PB_Ascii to read the line of the result Base64encoder
This is no problem here. He encrypts the string in its Unicode form and after decrypting he also uses a simple PeekS() to catch the string.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.