<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br clear="all"></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div class="gmail_default" style="font-size:small">Solved. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thank you very much</div><br><span class="gmail_default" style="font-size:small">Regards</span><br><br>António Teixeira</div></div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Message: 3<br>
Date: Wed, 27 May 2020 22:05:03 +0200<br>
From: Tobias Boege <<a href="mailto:taboege@gmail.com" target="_blank">taboege@gmail.com</a>><br>
To: Gambas Mailing List <<a href="mailto:user@lists.gambas-basic.org" target="_blank">user@lists.gambas-basic.org</a>><br>
Subject: Re: [Gambas-user] Cipher<br>
Message-ID: <20200527200503.GA457647@highrise.localdomain><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
On Wed, 27 May 2020, Antonio Teixeira wrote:<br>
> Hi everyone,<br>
> <br>
> I am trying to use ciper with "AES-128-XTS" method but I am always getting<br>
> an error.<br>
> <br>
> hCipherText = Cipher[sAlgorithmus].Encrypt(sPlain, sKey, sInitVector)<br>
> <br>
> In my case sPlain is a string with numbers, skey is an uuid<br>
> ("cbfcc1173b5a4b83ae9a355079aae54c") and no mater the size of sInitVector I<br>
> always get the error : InitVector length does not match method of FMain in<br>
> line....<br>
> <br>
> Any help please?<br>
> <br>
<br>
The IV length for AES-128-XTS is 16 and I get no problems executing this:<br>
<br>
#!/usr/bin/env gbs3<br>
<br>
Use "gb.openssl"<br>
<br>
Public Sub Main()<br>
Dim sKey As String = "cbfcc1173b5a4b83ae9a355079aae54c"<br>
Dim sIV As String = "0123456789abcdef"<br>
Dim hCrypt As CipherText<br>
<br>
Print "KeyLength:", Cipher["AES-128-XTS"].KeyLength == Len(sKey)<br>
Print "IvLength:", Cipher["AES-128-XTS"].IvLength == Len(sIV)<br>
hCrypt = Cipher["AES-128-XTS"].Encrypt(Format$(Now), sKey, sIV)<br>
Print "CipherText:", Base64$(hCrypt.Cipher)<br>
Print "Decrypted:", Cipher["AES-128-XTS"].Decrypt(hCrypt)<br>
End<br>
<br>
==========================================================================<br>
<br>
KeyLength: True<br>
IvLength: True<br>
CipherText: 6NuzSxByac+p+DD2qLuRmqpTTw==<br>
Decrypted: 05/27/2020 21:59:27<br>
<br>
Regards,<br>
Tobias<br>
<br>
-- <br>
"There's an old saying: Don't change anything... ever!" -- Mr. Monk<br><br>
</blockquote></div></div>