PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Challenge with Crypt/Uncrypt
Challenge with Crypt/Uncrypt
Débuté par Sam, 19 avr. 2021 18:57 - 2 réponses
Membre enregistré
2 messages
Posté le 19 avril 2021 - 18:57
Dear All,

I am struggling to crack an encryption nut.

I have the code below to save and retrieve an encrypted password. I expect the displayed result to be the original password entered but this is not the case.

Any advice will be appreciated.

======================================
gpwuser.Name=Crypt(gpwuser.Password,"vintage53")
HModify(gpwuser)
Info(gpwuser.Password, Uncrypt(gpwuser.Name,"vintage53"))
======================================
I expect the two displayed results to be gpwuser.Password, but it is not so.

Thanks.

Sam.
Membre enregistré
948 messages
Popularité : +30 (92 votes)
Posté le 20 avril 2021 - 00:13
Coucou Sam,

Two way to fix this issue.

1) Use crypteAnsi
gpwuser.Name=Crypt(gpwuser.Password,"vintage53", crypteAnsi)
HModify(gpwuser)
Info(gpwuser.Password, Uncrypt(gpwuser.Name,"vintage53", crypteAnsi))

2) Change the type of 'gpwuser.Name' & 'gpwuser.Password' to UNICODE.

---
#lapiraterienestjamaisfinie

Posté le 20 avril 2021 - 14:39
two things:

1. most of the time, encrypting a password is NOT best practice. You should instead HASH it, and there is no coming back from that, which would make your question moot.

2. If you are in a very rare case where encrypting/decrypting passwords is necessart (a password manager is on of those cases), then you should be aware that the RESULT of an encryption is a BINARY and should be stored as such (in a binary memo). As it can contain binary ZEROs, your decryption will not work in SOME cases (when there are zeros, which is the string ending flag).

So either store it as binary in a binary memo, or transform the result of the encryption in hexa or base64