[Gambas-user] Cipher doesn't read ciphered text

T Lee Davidson t.lee.davidson at gmail.com
Wed Sep 30 05:47:45 CEST 2020

On 9/29/20 9:57 AM, Rolf-Werner Eilert wrote:
> This is the code, it's from the example and slightly altered. I used a TextEdit to show the results, then saved the crypted text 
> to investigate with a hex editor. (I use My.File here, as the original one contains a name.)
>    t$ = File.Load("/klein/kartei/T18/My.File")
>    't$ = "Hallo öäüß"
>    sCipher = Cipher["AES-256-CBC"].EncryptSalted(t$, "secret")
>    TextEdit1.Text = "Cipher text (base64): " & Base64$(sCipher) & Chr$(10)
>    sData = Cipher["AES-256-CBC"].DecryptSalted(sCipher, "secret")
>    TextEdit1.Text &= "Decrypted: " & sData & Chr$(10)
>    File.Save("~/Gambas3/testEditor/test.cipher", sCipher)
> It fails in the line "sDate = Cipher...", so it cannot decrypt the string it crypted before. I tried another, even longer file, 
> and it ran flawlessly. So I cannot make out what caused the error.
> Both files are made up the same way, they contain a CR+LF pair after each line to make the files compatible to an older Windows 
> program that reads them. But that doesn't seem to be the reason.

Well I En/Decrypted a couple of text files using that example code. I even changed the line endings to CR+LF and just CR, 
though, now that I think about it, it really shouldn't matter. No problems; it decrypted flawlessly.


More information about the User mailing list