
Hashing vs. Encryption
Question:
Hi, I am writing a small program in VB that would allow to encrypt and save a string in to a file or decrypt a string from a file and display it in a form.
The EncryptStringENC and DecryptStringENC work fine. However, I was told to use the HashAlgorithm - "sha1". I don't quite understand the hashing, what is the purpose of hashing? If I use HashBytesENC method then how do I decode the hashed string? Is the HashAlgorithm property to be used toghether with the EncryptStringENC and DecryptStringENC methods?
I would appreciate it very much if you could please, clarify this for me.
Answer:
Hashing takes any amount of data (binary or text) and creates a constant-length hash representing a checksum for the data. For example, the hash might be 16 bytes. Different hashing algorithms produce different size hashes. You obviously cannot re-create the original data from the hash, but you can hash the data again to see if the same hash value is generated. One-way Unix-based passwords work this way. The password is stored as a hash value, and to log onto a system, the password you type is hashed, and the hash value is compared against the hash of the real password. If they match, then you must've typed the correct password.
|