irum
irum

Reputation: 11

Vb.net: Get md5 hashcode result in integer form

My problem is to generate md5 hash code of input string and return result in integer form, because I need to do arithmetic operation on result.

Upvotes: 0

Views: 1734

Answers (1)

Magnus
Magnus

Reputation: 46929

md5 is 128 bit so you would need to use BigInteger

Dim str = "Test"
Dim md5 = System.Security.Cryptography.MD5.Create()
Dim hash = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(str))
Dim i = New System.Numerics.BigInteger(hash)

And apply a modulus operation

Dim result = i Mod 90329434 'Returns 30719684

Upvotes: 2

Related Questions