|
|
|
Joined: Jan 2004
Posts: 2,127
Hoopy frood
|
OP
Hoopy frood
Joined: Jan 2004
Posts: 2,127 |
Update: Since $decode isn't supposed to recognize the chunks parameter anymore, the 1st issue for $decode() not recognizing chunks parameter is no longer an issue. And probably isn't worth the grief to have $encode support chunks in the context of encrypting strings either. Also, are you saying that there is an issue with $decode() ie. that it is not decoding to the original $encode()ed text correctly? Yes $decode can decode the original text, but only if $encode did not use a chunk=N value. And in that situation, $decode ignores the chunk number, and decodes the entire string. The only changed behavior is when I change chunk to 0, where it returns 1 character that changes depending on the beginning of the original string.
//var %chunk 2 , %switch mc , %a $encode($regsubex($str(x,150),/x/g,$base(\n,10,10,3)), %switch,key) | echo -a %a -> $chr(22) $decode(%a,%switch,key,%chunk)
How are you testing to compare $encode() with OpenSSL?
I'm trying to match the ECB encryption first, assuming there could be fewer things to go wrong, before moving on to matching CBC, but I can't get ECB to match either.
alias OpenSSL_test {
var %opensslexe C:\path\openssl-1.1.0h-win32-mingw\openssl.exe
var %testfile test.dat
var %testout test.out
var %password gryffczmj
var %inputstring $str(3,16)
echo -a ===== | if ($isfile(%testout)) remove %testout
write -cn $qt(%testfile) %inputstring
echo -a filesize %testfile should be $len(%inputstring) : $file(%testfile).size
var %a enc -bf-ecb -in %testfile -out %testout -nosalt -p -pass pass: $+ %password
echo -a commandline seen by OpenSSL: %a
run cmd /k %opensslexe %a
echo -a openssl window shows password is: $upper($left($sha256(%password),32))
echo -a waiting 2 seconds for OpenSSL to diskwrite
var %ticks $ticks + 2000 | while ($ticks < %ticks) noop
echo -a bread %testout 0 $file(%testout).size &v1
bread %testout 0 $file(%testout).size &v1
echo 3 -a size created by OpenSSL => $bvar(&v1,0)
bset -tc &v2 1 %inputstring
noop $encode(&v2,bme,%password)
echo -a remove only the base64 from &v2 => $decode(&v2,bm)
echo 3 -a $bvar(&v1,0) data created by OpenSSL: $bvar(&v1,1-)
echo 4 -a $bvar(&v2,0) data created by $ $+ encode: $bvar(&v2,1-)
return
}
Last edited by maroon; 30/11/18 10:25 PM.
|
|
|
Entire Thread
|
$encode(data,<c|cr|e|er>,key,string) bug
|
maroon
|
07/12/17 07:37 PM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
Khaled
|
07/12/17 08:08 PM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
maroon
|
30/11/18 10:27 AM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
Khaled
|
30/11/18 11:23 AM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
maroon
|
30/11/18 06:37 PM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
maroon
|
01/12/18 03:37 AM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
Khaled
|
01/12/18 10:59 AM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
maroon
|
03/12/18 10:03 PM
|
Re: $encode(data,<c|cr|e|er>,key,string) bug
|
Khaled
|
01/12/18 09:46 AM
|
|
|
|
|
|
|