Vb. NET string hashing algorithm

Source: Internet
Author: User
Tags end hash net string

Time33 is good at both efficiency and randomness. For a hash function, the criteria for evaluating its merits should be randomness, that is, the average degree of probability of entering the hash table for each unit (cell) of any group of specimens, because the more average the probability, the more evenly the data is distributed in the table, and the higher the space utilization rate of the table.
Times33 's algorithm is very simple, is constantly multiply by 33, see the following algorithm prototype.
hash (i) = hash (i-1) * + str[i]
The code is as follows:
Public Class Form1
Private Sub button1_click (sender as System.Object, E as System.EventArgs) Handles Button1.Click
Dim Myhash as ULong = 0
Dim mystr as String = TextBox1.Text
For i as Integer = 0 to Len (mystr)-1
Myhash = Myhash * + STRINGS.ASCW (mystr (i))
Next
TextBox2.Text = Myhash
End Sub
End Class

This article links http://www.cxybl.com/html/bcyy/net/20120604/27930.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.