BKDR Hash

BKDR is a simple hash function using a strange set of possible seeds which all constitute a pattern of 31....31...31 etc.



									Public Shared Function BKDRHash(str As String) As UInteger
	Dim seed As UInteger = 131
	Dim hash As ULong = 0
	Dim i As UInteger = 0

	For i = 0 To str.Length - 1
		hash = ((hash * seed) + CByte(AscW(str(CInt(i)))) And UInteger.MaxValue)
	Next

	Return hash
End Function
								


Example

									Dim data = "jdfgsdhfsdfsd 6445dsfsd7fg/*/+bfjsdgf%$^"
Dim value = BKDRHash(data)
								


Output

									3255416723