Does VB 2008 Express Edition have?
Does it have something built in so that you can encrypt a single form? My program contains a log in form and I want to encrypt just that one form so that no one can find out the password.
Answers
you cannot encrypt code behind the forms. You have to store that password somewhere outsite your program and have it encrypted.
For that, this simple encryption works great. I had posted it earlier somewhere here
http://www.codeguru.com/csharp/.net/net_security/encryption/article.php/c10343/
Thanks
♦ My Blog ♦ My Facebook ♦ YOUR Place to have fun time ! ♦ Awesome RPG Action Game- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorWednesday, November 11, 2009 9:11 AM
- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorWednesday, November 11, 2009 9:10 AM
- This should get you going again:
Imports System Imports System.IO Imports System.Security.Cryptography Imports System.Text Namespace ConsoleApplication1 Class Program Private Shared Sub Main(ByVal args As String()) Console.WriteLine("Enter Password:") Dim testPassword As [String] = Console.ReadLine() Dim testEncryption As [String] = EncryptString(testPassword) Console.WriteLine() Console.WriteLine([String].Format("Password {0} encrypts to {1}", testPassword, testEncryption)) If validPassword.Equals(testEncryption) Then Console.WriteLine("you are in") Else Console.WriteLine("bad password") End If End Sub Private Shared rgbIV As Byte() = Encoding.ASCII.GetBytes("asdfikygresonlhz") Private Shared key As Byte() = Encoding.ASCII.GetBytes("a;lsfiasdklixk,adfmasdl;k';asdfi") ' matches "brothers" Private Shared validPassword As String = "K8f6CqTHUdlhYGiX+IfuXQ==" Public Shared Function EncryptString(ByVal ClearText As [String]) As [String] Dim encryptedText As [String] = [String].Empty Using ms As New MemoryStream() Dim rijn As SymmetricAlgorithm = SymmetricAlgorithm.Create() Using cs As New CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write) Dim clearTextBytes As Byte() = Encoding.UTF8.GetBytes(ClearText) cs.Write(clearTextBytes, 0, clearTextBytes.Length) End Using encryptedText = Convert.ToBase64String(ms.ToArray()) End Using Return encryptedText End Function End Class End Namespace
- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorTuesday, November 10, 2009 6:30 AM
- Proposed As Answer byjgalley Sunday, November 08, 2009 4:18 AM
All Replies
- Sure,Depending on how "secure" you want you could do anything from home grow your own ASCII rotation cypher or use a proper one.Here is an example of encrypting the contents of a file, though it could just as easily be used to encrypt a string.
There isnt any need to encrypt the whole form (even if it is possible).Does it have something built in so that you can encrypt a single form? My program contains a log in form and I want to encrypt just that one form so that no one can find out the password.
Instead encrpyt the password and store it in the database. When the user enters the password in the form, encrpyt it and compare it withe the value in DB.
Ganesh Ranganathan
[Please mark the post as answer if it answers your question]
blog.ganeshzone.net- Right now my password looks like this:
The entire form doesn't have to be encrypted I just need enough of it encrypted so that no one can find out the password.Dim myPassword As String = "brothers"
Does it have something built in so that you can encrypt a single string My program contains a log in form and I want to encrypt the string that contains the password so that no one can find out the password. My desktop is XP and my laptop is Vista I do half of my programming from one computer and half from the other that's why I'm asking if it has something built in that can do this.
- Merged byMartin Xie - MSFTMSFT, ModeratorWednesday, November 11, 2009 9:11 AMMerge it to keep them in the same topic.
you cannot encrypt code behind the forms. You have to store that password somewhere outsite your program and have it encrypted.
For that, this simple encryption works great. I had posted it earlier somewhere here
http://www.codeguru.com/csharp/.net/net_security/encryption/article.php/c10343/
Thanks
♦ My Blog ♦ My Facebook ♦ YOUR Place to have fun time ! ♦ Awesome RPG Action Game- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorWednesday, November 11, 2009 9:11 AM
- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorWednesday, November 11, 2009 9:10 AM
- on second thought, you could store MD5 hash of some string in your program in some variable and when user enters password, MD5 it and compare with stored hash.
anyway..
Thanks
♦ My Blog ♦ My Facebook ♦ YOUR Place to have fun time ! ♦ Awesome RPG Action Game - Please don't double post:
http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/6cb0dae5-82c0-419c-a741-12f2f1c242e9
You can find plenty of information with the below Google link:
http://www.google.com/search?q=string+encryption+visual+basic+.net&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1
Paul ~~~~ Microsoft MVP (Visual Basic) My desktop uses XP and my laptop uses Vista. My program is on the laptop and I noticed when I went to that Microsoft link that is only good for XP computers. Is there way to encrypt on a Vista computer? Also the reason I want to encrypt a whole form is because the organization that I am making this for they don't want the information in the program to be available for just anyone to access it and as of right now if you were to right click the program when you publish it and click open with Notepad then you can view ALL of the text that is in the program. Therefore, I need to encrypt 2 forms not just one.
- This should get you going again:
Imports System Imports System.IO Imports System.Security.Cryptography Imports System.Text Namespace ConsoleApplication1 Class Program Private Shared Sub Main(ByVal args As String()) Console.WriteLine("Enter Password:") Dim testPassword As [String] = Console.ReadLine() Dim testEncryption As [String] = EncryptString(testPassword) Console.WriteLine() Console.WriteLine([String].Format("Password {0} encrypts to {1}", testPassword, testEncryption)) If validPassword.Equals(testEncryption) Then Console.WriteLine("you are in") Else Console.WriteLine("bad password") End If End Sub Private Shared rgbIV As Byte() = Encoding.ASCII.GetBytes("asdfikygresonlhz") Private Shared key As Byte() = Encoding.ASCII.GetBytes("a;lsfiasdklixk,adfmasdl;k';asdfi") ' matches "brothers" Private Shared validPassword As String = "K8f6CqTHUdlhYGiX+IfuXQ==" Public Shared Function EncryptString(ByVal ClearText As [String]) As [String] Dim encryptedText As [String] = [String].Empty Using ms As New MemoryStream() Dim rijn As SymmetricAlgorithm = SymmetricAlgorithm.Create() Using cs As New CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write) Dim clearTextBytes As Byte() = Encoding.UTF8.GetBytes(ClearText) cs.Write(clearTextBytes, 0, clearTextBytes.Length) End Using encryptedText = Convert.ToBase64String(ms.ToArray()) End Using Return encryptedText End Function End Class End Namespace
- Marked As Answer byMartin Xie - MSFTMSFT, ModeratorTuesday, November 10, 2009 6:30 AM
- Proposed As Answer byjgalley Sunday, November 08, 2009 4:18 AM

