amir100 Posted March 14, 2004 Posted March 14, 2004 Hi everyone, Greetings from me to all of you. I'm a newbie here :D . Well anyway, I need to ask something. I am trying to encrypt a password. I am using the MD5CryptoServiceProvider Class (Any other suggestions???). To compute the hash code, that class has a method called ComputeHash. This method accepts an array of Bytes as its argument. So ... the password were given in type String. I've look in the documentation, but I can't find anything about converting a String to an array of Bytes. So ... I can't continue my work. Up to this point, that's the last thing I need to do to finish my work. Please help. Thanks. -amir Quote Amir Syafrudin
Administrators PlausiblyDamp Posted March 14, 2004 Administrators Posted March 14, 2004 Something like the following any use Dim md As New System.Security.Cryptography.MD5CryptoServiceProvider Dim input As String = "Test String" Dim result() As Byte = md.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(input)) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
DR00ME Posted March 14, 2004 Posted March 14, 2004 Dim MyString As String = "yadda yadda yaa" Dim MyByteArray() As Byte Dim MyEncoding As New System.Text.ASCIIEncoding MyByteArray = MyEncoding.GetBytes(MyString) Quote "Everything should be made as simple as possible, but not simpler." "It's not that I'm so smart , it's just that I stay with problems longer ." - Albert Einstein
amir100 Posted March 15, 2004 Author Posted March 15, 2004 Thanks to DR00ME and PlausiblyDamp. You know, below is my code ... '===Hashing current password For Each character As Char In tmpPass currPass(0) = System.Convert.ToByte(character) cryptedPass = Me.crypter.ComputeHash(currPass) currentPass = currentPass & cryptedPass(0).ToString Next '=== I actually convert one character by one character in the input String to Byte and then I hash that character. It's kind a straight forward isn't it. :D Well anyway, thanks again. :) Quote Amir Syafrudin
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.