[Gambas-user] Usage of openssl.EncryptSalted

Marco Ancillotti gambas at servinfo.it
Wed May 31 12:27:20 CEST 2023


I'm trying to use cipher["DES3"].Encrypt in the place of EncryptSalted ( 
it seem to be the right call as it take key and iv ) but
it say that my key lenght is wrong.

Using:
Print "K :" & Cipher["DES3"].KeyLength
Print "IV:" & Cipher["DES3"].IvLength

I found that key length is 24 and iv is 8 but I have a key length of 48 
and a iv of 16 and shell openssl get those without any
problem.

Is that a bug ?

Thanks in advence,
Marco.



Il 30/05/23 17:59, Marco Ancillotti ha scritto:
>
> Hi all.
>
> I'm trying to replicate a des3 encryption without shell using only 
> gambas but I get different output.
>
> This is my example code:
>
> #!/usr/bin/env gbs3
>
> USE "gb.openssl"
>
> ' Key
> dim K as string="8aa69be1566a1dff572e102ed7266da674524d78ea8b933a"
> ' Init Vector
> dim IV as string="7eec1ceeaebc9828"
> ' string to encrypt
> dim pwd as string="1234567812345678"
>
> print Cipher["DES3"].EncryptSalted(pwd,K,IV)
>
> shell "printf \"" & pwd &  "\"" &
>      " | openssl des3 -a -nopad " &
>      "-K \"" & K & "\" " &
>      "-iv \"" & IV & "\""
>
> I get the right output from the shell openssl call but I can't 
> replicate with gambas.
>
> What's wrong ?
>
> thank's in advance,
> marco.
>
>
>
>
> ----[http://gambaswiki.org/wiki/doc/netiquette  ]----

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230531/4254f87b/attachment.htm>


More information about the User mailing list