Dear all,
I would like to encrypt email addresses and store them into database character fields.
When I need the email I have to decrypt the string to its original email address.
Using the encrypt/decrypt functions I get memptr and not character strings.
Using the encrypt function the input can be a character and output is a memptr.
Could try to get the character string out of this memptr to store this character string.
Using the decrypt function the input can be a memptr. So I could put the encrypted character string into it?
Output is a memptr and extract the character out of it. Question will this be the original email address?
Who has some experience with this? Could it work like this?
Regards,
Peter Wokke
base64-encode and base64-decode are your friends:
def var rkey as raw.
def var lcc as longchar.
rkey = generate-random-key.
lcc = base64-encode( encrypt( "my@mail.com", rkey ) ).
message
string( lcc )
decrypt( base64-decode( lcc ), rkey )
view-as alert-box.
Out of curiosity: why?
The tag says it all: GDPR
Stefan,
Thank you to forward those friends.
I use generate-pbe-key to avoid to store this key in the database as well.
I can message this decrypt( base64-decode( lcc ), rkey ).
But have to convert it back to a character string as email address.
User should be able to adjust when needed.
Have to forward it as character string to PostNL.
If you can help on this I be thankful.
Kind regards,
Peter
encryptCharacter.p
define input parameter pcToEncrypt as character no-undo.
define output parameter pcEncrypted as character no-undo.
define variable rKey as raw no-undo.
define variable lcEncoded as longchar no-undo.
rKey = generate-pbe-key("Progress").
lcEncoded = base64-encode( encrypt( pcToEncrypt, rkey ) ).
pcEncrypted = string(lcEncoded).
decryptCharacter.p
define input parameter pcToDecrypt as character no-undo.
define output parameter pcDecrypted as character no-undo.
define variable rKey as raw no-undo.
define variable lcEncoded as longchar no-undo.
define variable rEncoded as raw no-undo.
rKey = generate-pbe-key("Progress").
rEncoded = decrypt( base64-decode( pcToDecrypt ), rkey ).
lcEncoded = get-string(rEncoded,1,length(rEncoded)).
pcDecrypted = string(lcEncoded).
Dear All.
With those two procedures I can use to encrypt and decrypt character strings like emails.
there is another discussion related to this issue:
community.progress.com/.../117081
Still have to work on hiding the key.
Peter
Hiding the key shouldn't be very difficult. It is essentially a user-secret and should, as such, not reside in your code. Put it in the registry, a file, or somewhere else, but not in the code. Off course you should be able to recreate the key, in case it's lost.