[Gambas-user] Can I encrypt a string

Mayost Sharon sharon at 455.co.il
Wed Jul 3 15:50:24 CEST 2019


hello

First
Thank you

I ran the code according to this documentation:
http://gambaswiki.org/wiki/comp/gb.openssl/cipher

It gives such output:
Cipher text (base64): U2FsdGVkX1/v8DsOOaNFFEnWaJm6I0RN2O9zt+JrLZg=
Decrypted: Hello there^E^E^E^E^EHello there
ERROR: Decryption failed


It adds signs
^E^E^E^E^E

And writes two times:
Hello there



---------- Original Message -----------
From: T Lee Davidson <t.lee.davidson at gmail.com>
To: user at lists.gambas-basic.org
Sent: Wed, 3 Jul 2019 07:13:26 -0400
Subject: Re: [Gambas-user] Can I encrypt a string

> You might want to take a look at the gb.openssl component:
http://gambaswiki.org/wiki/comp/gb.openssl
> 
> Or, perhaps gb.crypt if you want something simpler for passwords:
http://gambaswiki.org/wiki/comp/gb.crypt/crypt
> 
> ___
> Lee
> 
> On 7/2/19 4:06 PM, Mayost Sharon wrote:
> > hello
> > 
> > Can I encrypt a string
> > 
> > Such as PHP
> > $plaintext = "my string sharon";
> > $ivlen = openssl_cipher_iv_length($cipher="AES-128-CBC");
> > $key = "mykey12345678";
> > $iv = openssl_random_pseudo_bytes($ivlen);
> > $ciphertext_raw = openssl_encrypt($plaintext, $cipher, $key, $options=OPENSSL_RAW_DATA,
> > $iv);
> > $hmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary=true);
> > $ciphertext = base64_encode( $iv.$hmac.$ciphertext_raw );
> > 
> > thenk
> > 
> > ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> >
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
------- End of Original Message -------



More information about the User mailing list