|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
MD5 or SHA1 or ???I have many questions. 1. I need to create a Hash value of a String. Does anybody has a function? I am havin troubles doing my own function, because i fail converting a Byte() to a String. 2. What is the most security algorithm? MD5, SHA1, SHA512?? 3. What is the difference bettewn Dim x as byte() and Dim x() as Byte 4. I debug my own function, i am getting surprise when i enter a long string like 500 characters, and ComputeHash return me a string of 35 characters!! I think i am doing something wrong here. Thanks Alfredo Barrientos > 1. I need to create a Hash value of a String. Does anybody has a private void button1_Click(object sender, EventArgs e)> function? I am havin troubles doing my own function, because i fail > converting a Byte() to a String. { string s = "My string to hash."; byte[] ba = Encoding.UTF8.GetBytes(s); byte[] md5Hash = MD5.Create().ComputeHash(ba); string base64Hash = Convert.ToBase64String(md5Hash); Console.WriteLine("MD5 hash of string is:" + base64Hash); Console.WriteLine("MD5 hash length in bytes:" + md5Hash.Length); byte[] sha1Hash = SHA1.Create().ComputeHash(ba); base64Hash = Convert.ToBase64String(sha1Hash); Console.WriteLine("SHA1 hash of string is:" + base64Hash); Console.WriteLine("SHA1 hash length in bytes:"+ sha1Hash.Length); byte[] sha256Hash = SHA256.Create().ComputeHash(ba); base64Hash = Convert.ToBase64String(sha256Hash); Console.WriteLine("SHA256 hash of string is:" + base64Hash); Console.WriteLine("SHA256 hash length in bytes:" + sha256Hash.Length); } // Output: MD5 hash of string is:DS4DrhUB33YBfoK8S7PJ6g== MD5 hash length in bytes:16 SHA1 hash of string is:TNH/hNKWZKVDK5/RbTgD+9c4lQg= SHA1 hash length in bytes:20 SHA256 hash of string is:M3GLzAsXhdtIF+pcZ/fWDD5rcfbDptb3RzkFdmM/0jE= SHA256 hash length in bytes:32 > 2. What is the most security algorithm? MD5, SHA1, SHA512?? The strength of the hash follows the order you listed.> As you see above, the hash is always the same size depending on the hash > 3. What is the difference bettewn Dim x as byte() and Dim x() as Byte > > 4. I debug my own function, i am getting surprise when i enter a long > string like 500 characters, and ComputeHash return me a string of 35 > characters!! I think i am doing something wrong here. algo you pick. md5 is 16 bytes, sha1 is 20, sha256 is 32, etc. -- William Stacey [MVP] Thank you very much William,
But, I dont understand how is possible to get a diferent hash value for numbers from 1 to 1 000 000 000 000 000 000 000 000 000 000 000 000, if my maximun combination is 1 00 000 000 000 000 000 000 000 000 000 000 - 1? Thanks, Alfredo Barrientos The hash space is finite. The data space that you might hash is infinite.
It follows there is an infinite number of hash collisions. -- Show quoteHide quoteWilliam Stacey [MVP] "Alfredo" <abarrien***@gmail.com> wrote in message news:1123783237.815413.285130@g47g2000cwa.googlegroups.com... > Thank you very much William, > > But, I dont understand how is possible to get a diferent hash value for > numbers from 1 to 1 000 000 000 000 000 000 000 000 000 000 000 000, if > my maximun combination is 1 00 000 000 000 000 000 000 000 000 000 000 > - 1? > > Thanks, > > Alfredo Barrientos > Hello Alfredo,
hash algorithms (especially the more sophisticated ones) are complex beasts. Grab a copy of Schneier "Applied Cryptography" if you want the details. --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > Thank you very much William, > > But, I dont understand how is possible to get a diferent hash value > for numbers from 1 to 1 000 000 000 000 000 000 000 000 000 000 000 > 000, if my maximun combination is 1 00 000 000 000 000 000 000 000 000 > 000 000 - 1? > > Thanks, > > Alfredo Barrientos > Thank you very much.
How many algorithms does .net support? Thanks, Alfredo Barrientos Hello Alfredo,
http://www.leastprivilege.com/SupportedHashingAlgorithmsForPasswordDeriveBytes.aspx --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > Thank you very much. > > How many algorithms does .net support? > > Thanks, > > Alfredo Barrientos >
X509 digital certificate for offline solution
How to send certificate for client authentication? String to byte[] & back using Base64 Create an Event Log on a Least Privilege User Account Bad Data error in DES encryption Securing a control assembly against use of foreign assemblies sn.exe exit code documentation ? Extra '\0' chars after decryption How to impersonate while creating a User via System.DirectoryServi Change a windows user's password with C#? |
|||||||||||||||||||||||