mark007 Posted October 19, 2005 Posted October 19, 2005 Ok, this has been driving me insane for the last hour! I have the following function: Public Function EncryptPass(ByVal s As String) As String Dim encoder As New System.Text.UTF8Encoding Dim md5Hasher As New System.Security.Cryptography.MD5CryptoServiceProvider Return encoder.GetString(md5Hasher.ComputeHash(encoder.GetBytes(s))) End Function To encrypt passwords. However a particular password is returning a null byte after the hash has been replaced. I'm pretty sure this is what is causing my problems. Earlier in an area using an encrypted pass I was getting the following results in the command window: Me.m_Pass.length ==>12 me.m_Pass.toString.length ==>4 !!!! I finally traced it back to the hash returning the null byte which I think is where things are going wrong. Surely someone must have come across this before - any ideas for a solution? Thanks. :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
mark007 Posted October 19, 2005 Author Posted October 19, 2005 Would still be intrigued by replies but have solved it for now by adjusting the db to store binary data rather than strings and then have just assigned the byte array to the field. Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
Administrators PlausiblyDamp Posted October 19, 2005 Administrators Posted October 19, 2005 Try Public Function EncryptPass(ByVal s As String) As String Dim encoder As New System.Text.UTF8Encoding Dim md5Hasher As New System.Security.Cryptography.MD5CryptoServiceProvider Return Convert.ToBase64String(md5Hasher.ComputeHash(encoder.GetBytes(s))) End Function Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mark007 Posted October 25, 2005 Author Posted October 25, 2005 Not had chance to try it bu the above looks good - thanks! :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
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.