473,395 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to decrypt password from database in vb.net?

Prathap
37
Could someone please help me to decrypt password from database.
Here is my code to encrypt password
Expand|Select|Wrap|Line Numbers
  1.  Dim a, enc As String
  2.     Private Sub encrypt(ByVal a)
  3.         Try
  4.             Dim encData_byte() As Byte = System.Text.Encoding.ASCII.GetBytes(a)
  5.             enc = Convert.ToBase64String(encData_byte)
  6.             TextBox4.Text = enc
  7.         Catch ex As Exception
  8.             MsgBox("Error in Creating Encryption")
  9.         End Try
  10.     End Sub
  11.  Dim str As String = "Data Source=NET3\SQLEXPRESS;Initial Catalog=pos;Persist Security Info=True;User ID=sa;Password=password"
  12.     Dim ds As New DataSet
  13.     Dim adp As New SqlClient.SqlDataAdapter
  14.     Dim con As New SqlClient.SqlConnection
  15.  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  16.  
  17.         If TextBox3.Text <> "" Then
  18.             Call encrypt(TextBox3.Text)
  19.         Else
  20.             MsgBox("Field Missing", MsgBoxStyle.OkOnly, "Error")
  21.  Try
  22.                 con.ConnectionString = str
  23.                 adp = New SqlClient.SqlDataAdapter("insert into Login(userid,username,password) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "') ", con)
  24.                 adp.Fill(ds)
  25.                  MsgBox("Inserted", MsgBoxStyle.OkOnly, "Message")
  26.             Catch ex As Exception
  27.                 MsgBox(ex.Message)
  28.             End Try
  29.         End If
  30.     End Sub
  31. End Class
Dec 16 '11 #1
2 4960
Rabbit
12,516 Expert Mod 8TB
You converted to a base 64 string. To decrypt, just convert from a base 64 string. Also, that's a bad way to store passwords, it's only one step up from storing it as plaintext. The preferred method is to use a hash with a salt.
Dec 16 '11 #2
kadghar
1,295 Expert 1GB
Using a simple hash, like sha1 in VB.net is quite simple, since the libraries are already in your framework:

Expand|Select|Wrap|Line Numbers
  1. Dim sha1 As New System.Security.Cryptography.SHA1Cng
  2. Dim str2 As String = Convert.ToBase64String(sha1.ComputeHash(Encoding.Unicode.GetBytes(myPassword)))
Adding some salt is not much harder. And as you can see here, the hash has been converted into a B64 string, so you can store it as plain text.
Dec 16 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Bright | last post by:
Dear All I'm after a multi-User password database so that I can centrally store system passwords and give granular access to individuals based on their own unique authentication (possibly a...
2
by: Keith Henderson | last post by:
I have an applicaiton that needs to pass to to a 3rd party application a username and password. The name and password are not provided by or known by the user. They're also not for a connection...
4
by: hohans | last post by:
Hi all, I have an encryption class that encrypts and decrypts password using TripleDESCryptoServiceProvider. It was written originally in framework 1.0 and been working fine. And those...
1
by: Rick Gamble | last post by:
When the password recovery control sends forgotten passwords via email I get the message noted below. Is there a way to decrypt this to make it usable to the user who requested it? Please...
26
by: beporter | last post by:
First time poster here! Let me get straight to it... I'm currently not in a position that lets me interact with other developers face to face on a regular basis, and I am in need of some "round...
6
by: Ripendra007 | last post by:
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 ?
1
by: marcob | last post by:
Hello, I have a encrypted Access Database which I have to Update (from Access 2000 to Access 2007). The problem is, that the originally author is not available. Those anybody have some tool to...
19
by: dreamy | last post by:
can i ask how to encrypt an password in php code? then how to decrpty it after encrypt? thanks
5
by: simon2x1 | last post by:
how can i decrypt password with i encryted with md5 i try using mcrypt it did not work <?PHP $sql = "SELECT password FROM user WHERE email='$email_to'"; $result = mysql_query($sql); $rows =...
1
by: bigscorpio | last post by:
I am having a desperate struggle finding the correct connection string to connect my VB 2005 project to an Access 2003 database that is password protected! The connection string I using is string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.