alias OpenSSL_test-cbc {
;var %opensslexe C:\path\openssl-1.1.0h-win32-mingw\openssl.exe
;var %opensslexe C:\path\OpenSSL-Win32\bin\openssl.exe
var %opensslexe C:\path\Win32OpenSSL-1_0_2q\bin\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-cbc -in %testfile -out %testout -salt -p -pass pass: $+ %password
echo -a commandline seen by OpenSSL: %a
run cmd /k %opensslexe %a
echo -a waiting 2 seconds for OpenSSL to diskwrite
var %ticks $ticks + 2000 | while ($ticks < %ticks) noop
bread %testout 0 $file(%testout).size &v1
bread $qt(%testout) 0 $file(%testout).size &v2
; add base64 layer so $decode can remove it
noop $encode(&v2,bm) | noop $decode(&v2,bmc,%password)
echo 3 -a $bvar(&v1,0) data created by OpenSSL: $bvar(&v1,1-)
echo 3 -a $bvar(&v1,0) data created by OpenSSL: $bvar(&v1,1-).text
echo 4 -a $bvar(&v2,0) data created by $ $+ encode: $bvar(&v2,1-)
echo 4 -a $bvar(&v2,0) data created by $ $+ encode: $bvar(&v2,1-).text
return
}