hi,everyone i m creating a login page and i want to encrypt the password before insert that in to database and decrypt it before verification can enybody tell how to do this ?
How encrypt and decrypt password ?
Collapse
X
-
Tags: None
-
Originally posted by Ripendra007hi,everyone i m creating a login page and i want to encrypt the password before insert that in to database and decrypt it before verification can enybody tell how to do this ? -
Originally posted by hariharanmcayou should be aware of string manipulation and you can use some formula which will convert the actual string and which will getback to actual string..
thanx but i m not satisfied....ok bye the way can u tell me how to write algorithm for it ? or if any site from from where i can download or seen that algorithm...ok plz reply soonComment
-
Another alternative which I sometimes use is to encrypt the password into some other form, which you then store in the database, and then you check that the entered password encrypts to the same value for verification purposes.
This means the encryption doesn't need to be 'reversible' - you never need to get the password back from the stored value, so it's no use to anyone even if they steal the data, and you can encrypt the entered password before sending that for storing or verification, so you never send plain text passwords outside your application.
If you don't need to be particularly secure, here's a bit of PHP that you could easily convert to C or VB that turns a text password into a lightly-encrypted 'long integer'.
Store the result of the function as your password in the database. Then when you want to check a password, just hash the entered text and see if the result matches what was stored. That way you never store the actual password, and it is very difficult to turn the stored value back into anything usable.
Code:function hash($key) { $h = 0; for ($n = 0 ; $n < strlen($key) ; $n++) { $h = (($h & 0x3FAFCF) * 131) + ord($key{$n}); } return $h; }
SteveComment
-
Originally posted by Ripendra007thanx but i m not satisfied....ok bye the way can u tell me how to write algorithm for it ? or if any site from from where i can download or seen that algorithm...ok plz reply soon
and there are more search in gogle.
you should undersatnd the algoritham then use it
Good luck...Comment
-
Originally posted by SteveDouglasAnother alternative which I sometimes use is to encrypt the password into some other form, which you then store in the database, and then you check that the entered password encrypts to the same value for verification purposes.
This means the encryption doesn't need to be 'reversible' - you never need to get the password back from the stored value, so it's no use to anyone even if they steal the data, and you can encrypt the entered password before sending that for storing or verification, so you never send plain text passwords outside your application.
If you don't need to be particularly secure, here's a bit of PHP that you could easily convert to C or VB that turns a text password into a lightly-encrypted 'long integer'.
Store the result of the function as your password in the database. Then when you want to check a password, just hash the entered text and see if the result matches what was stored. That way you never store the actual password, and it is very difficult to turn the stored value back into anything usable.
Code:function hash($key) { $h = 0; for ($n = 0 ; $n < strlen($key) ; $n++) { $h = (($h & 0x3FAFCF) * 131) + ord($key{$n}); } return $h; }
Steve
Code:Thank you so much will meet with new questions bye ?
Comment
-
.NET has built in functions to do encryption and hashes
Here is a piece of code i use to create a MD5 Hash
Code:using System; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Web; public class Security { //********************************************************************* // // Security.Encrypt() Method // // The Encrypt method encrypts a clean string into a hashed string // //********************************************************************* public static string Encrypt(string cleanString) { Byte[] clearBytes = new UnicodeEncoding().GetBytes(cleanString); Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes); return BitConverter.ToString(hashedBytes); } }
Comment
Comment