Link to home
Start Free TrialLog in
Avatar of holgrave
holgraveFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Generate 12 character passkey from DateOfBirth and ZipCode

I am using VBScript and want some code that can generate a 12 character passkey using strDateOfBirth and strZipCode.

strDateOfBirth will be in format ddmmyyyy so 29/03/2004 would be 29032004.
This string will be a fixed length of 8 characters.

strZipCode will be of variable length and format as it could be a Zip/Post code from any where around the world.

I want the process to be reversible so given the 12 character (alphanumeric) passkey I can get the original DOB and Postcode from it.
ASKER CERTIFIED SOLUTION
Avatar of Shauli
Shauli

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shauli
Shauli

One correction in the sub to reverse :)

Public Sub Reverse_PassKey(ByVal fnPassKey As String)
Dim dayOfBirth As String, monthOfBirth As String, yearOfBirth As String, zLoop As Integer
'get initial data
dayOfBirth = Left(fnPassKey, 1)
monthOfBirth = Mid(fnPassKey, 2, 1)
yearOfBirth = Mid(fnPassKey, 3, 4)
'reverse day of birth
If Not IsNumeric(dayOfBirth) Then dayOfBirth = Asc(UCase(dayOfBirth)) - 55
'reverse DOB
strDateOfBirth = dayOfBirth & "/" & Val("&H" & monthOfBirth) & "/" & yearOfBirth   '<<< here the correction
'reverse zip
strZipCode = Right(fnPassKey, 6)
For zLoop = 1 To 6
    If Left(strZipCode, 1) = "0" Then strZipCode = Right(strZipCode, Len(strZipCode) - zLoop)
Next zLoop
End Sub

S