Jump to content

Data Encryption


Guest devils_acc06

Recommended Posts

Guest devils_acc06

Can anyone inform me how to insert encrypted data in database during new user registration registration process?Thanks in advance..... :) :) :)

Link to comment
Share on other sites

here is an article that is on use MD5 encryption to store passwords in a database.http://aspnet.4guysfromrolla.com/articles/103002-1.aspxNote: MD5 is not decyrptable (you cannot retreive the users password if they forget it, you'll have to give then a new one.)If you use SHA1 encryption, it is decryptable.

Link to comment
Share on other sites

Encryption:dim str as string = Encrypt(orginalstr, "12345678")

Private Shared Function Encrypt(ByVal strText As String, ByVal strEncrKey As String) As String			Dim byKey() As Byte = {}			Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}			Try				byKey = System.Text.Encoding.UTF8.GetBytes(Left(strEncrKey, 8))				Dim des As New DESCryptoServiceProvider				Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText)				Dim ms As New MemoryStream				Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write)				cs.Write(inputByteArray, 0, inputByteArray.Length)				cs.FlushFinalBlock()				Return Convert.ToBase64String(ms.ToArray())			Catch ex As Exception				Return ex.Message			End Try		End Function

Decryption:dim str as string = Decrypt(decryptedstr, "12345678")

Private Shared Function Decrypt(ByVal strText As String, ByVal sDecrKey As String) As String			Dim byKey() As Byte = {}			Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}			Dim inputByteArray(strText.Length) As Byte			Try				byKey = System.Text.Encoding.UTF8.GetBytes(Left(sDecrKey, 8))				Dim des As New DESCryptoServiceProvider				inputByteArray = Convert.FromBase64String(strText)				Dim ms As New MemoryStream				Dim cs As New CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write)				cs.Write(inputByteArray, 0, inputByteArray.Length)				cs.FlushFinalBlock()				Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8				Return encoding.GetString(ms.ToArray())			Catch ex As Exception				Return ex.Message			End Try		End Function

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...