What is the easiest way to encrypt password? The administrators should have the ability to reset if any user forgets the password.Neetu:
As has been pointed out, one way is using the Windows Crypto API (CAPI). VFP7 has a class in the FFC in _crypt.vcx that helps you use strong encryption in your programs:
loCrypt = NEWOBJECT("_cryptapi",HOME()+"\ffc\_crypt.vcx")
lcEncryptedString = ""
lcUserPassword = "Whatever the user wants as password"
lcKey = "Foxpro Rocks!"
loCrypt.EncryptSessionStreamString(lcUserPassword, lcKey, @lcEncryptedString)
? lcEncryptedString
You could use an option to decrypt the password or better yet, use a one-way hashing algorithm (also provided in the CAPI), that cannot really be decrypted but you can use to compare with the user's password saved in the system.
If the user forgets the password, an Admin could have a program switch that forces the user to create a new password upon nect entry, or depending on the company's security policy, a new temporary password is issued and the user has to type this new password, then he's immediately forced to create a new one.
These are just some ideas. There is of course much more that could be said to authenticate users before granting access to a system or sensitive data.
For more examples, check the samples provided with hte FFC or look at my article on the March/April 2002 issue of CoDe Magazine (
http://www.code-magazine.com)