Convert Hash to Letters and Numbers

Bernie

Well-known member
Joined
Aug 13, 2007
Messages
98
Programming Experience
3-5
The application is to create software registration codes from a seed. This is what I have so far:

VB.NET:
        Dim hash As HashAlgorithm
        Dim tmpCode As String       
        Dim codeBytes As Byte()     
        Dim seedBytes As Byte()     

        ' create hash as SHA1 ...
        hash = New SHA1Managed

        ' calculate the hash ...
        codeBytes = hash.ComputeHash(seedBytes)

        ' convert to string ...
        For Each b In codeBytes
            tmpCode += b.ToString("x2")
        Next
This gives me tmpCode at a string of hexadecimal values. If I do this;
VB.NET:
        'tmpCode = Convert.ToBase64String(codeBytes)
I get tmpCode with letters and numbers but also assorted other charactors.

What I want it so convert the byte array to letters and numbers only and not punctuation or other charactors. How do I avoid any of the non numeric or non alpha charactors?

Thanks for any ideas you have.

Bernie
 
I wanted to have both complete letters and numbers. I ended up using the base64 solution and picking out the non alpha/numeric numbers and replacing them with numbers. This somewhat weakness the process, but registration is more of keeping the honest more honest, hahahaha.

Bernie
 
Back
Top