Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello everyone , i'm a neewbie programmer with VB .
I created an algoritm that is linked to the MAC address and that return me a key that writed in an specify textbox let the programm run (just a simple licence unique for PC )
I'd like that the key generated must be generated from a new algoritm that contains something token from the email written in a textbox .

Specify , how can i convert a string like example123@example.com in a number ???

Cordially,
Nick
Posted
Comments
Sergey Alexandrovich Kryukov 1-Aug-13 22:32pm    
What do you call "VB", exactly?
—SA

Have a look at String.GetHashCode[^]

It would proably be best to use some sort of KeyedHashAlgorithm[^]

Best regards
Espen Harlinn
 
Share this answer
 
v2
Comments
Ron Beyer 1-Aug-13 20:31pm    
Make sure you read the Note in that link, there's no way to hash strings and guarantee uniqueness. +5 though.
Espen Harlinn 1-Aug-13 20:36pm    
Thanks Ron :-D
Check out

System.Text.AsciiEncoding.GetBytes[^]

and

Convert.ToBase64String[^]

The latter of which converts it to a base-64 number that can be converted back to the text. However there really isn't a way to convert the text to a number, have that number fit inside a numerical structure, and be unique to the text. BigInteger isn't big enough to handle that much data.

You could write your own hashing function, but even then its hard to guarantee a unique string.
 
Share this answer
 
Comments
Espen Harlinn 1-Aug-13 20:37pm    
Good points :-D
The simplest way may be to get its hash code:

http://msdn.microsoft.com/en-us/library/system.string.gethashcode.aspx[^]

Or you could try a different hashing algorithm.
 
Share this answer
 
Comments
Espen Harlinn 1-Aug-13 20:37pm    
Seems we agree ;-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900