Link to home
Start Free TrialLog in
Avatar of hmadhur
hmadhur

asked on

Inserting Encrypted String in Registry

Hello Everybody,

I am using CryptoAPI in VB to encrypt a string. The encryption is working very perfectly (Thanks to Davis Chapman's book).

Now the problem is to insert this string into Registry. I am using the API RegSetKeyValueEx to set the string. For eg. I want to set the String value EDate as the encrypted string. This EDate is in HKEY_LOCAL_MACHINE\SOFTWARE\Synx\ExpiryDate. The encrypted string is actually the expiry date for my activex control. In every initialize I read and decrypt this string to check the expiry date. If it has expired, my activex control locks itself and does not work untill the customer pays me for renewal. The API is not allowing me to write the Encrypted String. The .reg file is also not working. It writes simple string not the string with special characters. According to WinError.h the Error Code that returns is Access Denied (Error no 5).

Please tell me what I am doing is proper or is there a better way to do it?

Regards
Madhur
Avatar of vinnyd79
vinnyd79

It sounds like a permissions issue.Does it work if the user is logged in as administrator?
Perhaps you should try to store the string as binary data (REG_BINARY) instead. This might work better if the encrypted string contains non-printable characters
ASKER CERTIFIED SOLUTION
Avatar of emadat
emadat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hmadhur

ASKER

Hi emadat,
Thanks for the help. Even though the Access Denied is still there, the .reg merge file is working. I went through the MSDN articles. But they are a bit dangerous settings to play with because the user will have some previleges to access the registry and modify it. So better use the .reg merge file. :~)

Thanks and Regards
Madhur