[Gambas-user] Cipher
Tobias Boege
taboege at gmail.com
Wed May 27 22:05:03 CEST 2020
On Wed, 27 May 2020, Antonio Teixeira wrote:
> Hi everyone,
>
> I am trying to use ciper with "AES-128-XTS" method but I am always getting
> an error.
>
> hCipherText = Cipher[sAlgorithmus].Encrypt(sPlain, sKey, sInitVector)
>
> In my case sPlain is a string with numbers, skey is an uuid
> ("cbfcc1173b5a4b83ae9a355079aae54c") and no mater the size of sInitVector I
> always get the error : InitVector length does not match method of FMain in
> line....
>
> Any help please?
>
The IV length for AES-128-XTS is 16 and I get no problems executing this:
#!/usr/bin/env gbs3
Use "gb.openssl"
Public Sub Main()
Dim sKey As String = "cbfcc1173b5a4b83ae9a355079aae54c"
Dim sIV As String = "0123456789abcdef"
Dim hCrypt As CipherText
Print "KeyLength:", Cipher["AES-128-XTS"].KeyLength == Len(sKey)
Print "IvLength:", Cipher["AES-128-XTS"].IvLength == Len(sIV)
hCrypt = Cipher["AES-128-XTS"].Encrypt(Format$(Now), sKey, sIV)
Print "CipherText:", Base64$(hCrypt.Cipher)
Print "Decrypted:", Cipher["AES-128-XTS"].Decrypt(hCrypt)
End
==========================================================================
KeyLength: True
IvLength: True
CipherText: 6NuzSxByac+p+DD2qLuRmqpTTw==
Decrypted: 05/27/2020 21:59:27
Regards,
Tobias
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list