Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative to Social Security Numbers? 1

Status
Not open for further replies.

Floyd7

Programmer
May 23, 2007
35
US
Hi,

Is there a way to alias or mask social security numbers? I need to use them as unique ids for current and new enrollees.

I was wondering if a lookup table would work, where you switch a random autonumber for a social. If this will work, is it more secure than simply storing the socials?

Thank you all!
 
Howdy randy700 . . .
Tototootoo said:
[blue]Is there a way to alias or mask social security numbers? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
I'm having trouble. :(

So..if my command button is called button_7, when I enter your code, it goes in between Private Sub Command7_Click() and End Sub.

This doesn't seem to work.

 
Tototootoo . . .

Yes thats correct.

For testing put an unbound textbox in the header or footer of the form (so you can see results) and use that name in place of textboxName. If the name is [blue]Text22[/blue] then you should have:
Code:
[blue]Private Sub Command7_Click()

   Me![b]Text22[/b] = CipherSSN("123456789") 

End Sub[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Hmmm. The code you just gave me works, but the command button with the CipherSSN is giving me trouble.

Do I keep the Public Function CipherSSN(SSN As String) when it's in between the Sub?

Also, how do I call up the actual SSN field instead of the ("123456789") listed above?

Thank you!
 
Tototootoo . . .

Wow! . . . I thought I was giving you code for the command button you have, namely Command7. [surprise]

Post all the code of the button please . . .

and post the code you copied to the module in the modules window (you can copy and paste)

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Code:
<html>
<head>
<body>
Private Function Command7_Click()
   CipherSSN(SSN As String)
   Dim Mask As String, Build As String, x As Integer
   Dim Msg As String, Style As Integer, Title As String, DL As String
   
   DL = vbNewLine & vbNewLine
   
   If Len(SSN) <> 9 Then
      Msg = "SSN Must Be Exactly 9 Digits!" & DL & _
            "Check SSN '" & SSN & "' and try again . . ."
      Style = vbInformation + vbOKOnly
      Title = "SSN Not 9 Digits Error! . . ."
      MsgBox Msg, Style, Title
      CipherSSN = Null
   Else
      Do
         x = x + 1
         
         If Asc(Left(SSN, 1)) < 58 Then
            If (x Mod 2) = 0 Then
               Mask = 64
            Else
               Mask = 32
            End If
         Else
            If (x Mod 2) = 0 Then
               Mask = -64
            Else
               Mask = -32
            End If
         End If
         
         Build = Build & Chr(Asc(Mid(SSN, x, 1)) + Mask)
      Loop Until x = 9
      
      CipherSSN = Build
   End If
   

End Function
</body>
</html>
 
Tototootoo . . .

I looked at your latest post during lunch today and have been speechless since! Add to that your [blue]signing on as a programmer![/blue] [surprise] I'm gonna give this one more shot!

BTW . . . where is [blue]<html> <head> <body>[/blue] coming from (I sure hope its not throughout your code)? . . . [blue]Please answer this![/blue]

[purple]Delete all the code I gave you[/purple], then:

[tt][blue]Setting Up The Module
*********************
[/blue][/tt]
[ol][li]From the database window [blue]View[/blue] - [blue]Database Objects[/blue] - [blue]Modules[/blue]. This is the [blue]Modules Window![/blue][/li]
[li]From the menubar [blue]Insert[/blue] - [blue]Module[/blue][/li]
[li]Click [blue]Save[/blue] and name the module [blue]modCipher[/blue].[/li]
[li]At the top of the module window you should see:
Code:
[blue]Option Compare Database
Option Explicit[/blue]
If you don't see it, copy and paste from here.[/li]
[li]Drop down a couple of lines[/li]
[li]Copy/paste the following to the module:
Code:
[blue]Public Function CipherSSN(SSN As String)
   Dim Mask As String, Build As String, x As Integer
   Dim Msg As String, Style As Integer, Title As String, DL As String
   
   DL = vbNewLine & vbNewLine
   
   If Len(SSN) <> 9 Then
      Msg = "SSN Must Be Exactly 9 Digits!" & DL & _
            "Check SSN '" & SSN & "' and try again . . ."
      Style = vbInformation + vbOKOnly
      Title = "SSN Not 9 Digits Error! . . ."
      MsgBox Msg, Style, Title
      CipherSSN = Null
   Else
      Do
         x = x + 1
         
         If Asc(Left(SSN, 1)) < 58 Then
            If (x Mod 2) = 0 Then
               Mask = 64
            Else
               Mask = 32
            End If
         Else
            If (x Mod 2) = 0 Then
               Mask = -64
            Else
               Mask = -32
            End If
         End If
         
         Build = Build & Chr(Asc(Mid(SSN, x, 1)) + Mask)
      Loop Until x = 9
      
      CipherSSN = Build
   End If
   
End Function[/blue]
[/li]
[li]If you've made it this far check that the module code looks exactly . . . exactly like the following:
Code:
[blue]Option Compare Database
Option Explicit

Public Function CipherSSN(SSN As String)
   Dim Mask As String, Build As String, x As Integer
   Dim Msg As String, Style As Integer, Title As String, DL As String
   
   DL = vbNewLine & vbNewLine
   
   If Len(SSN) <> 9 Then
      Msg = "SSN Must Be Exactly 9 Digits!" & DL & _
            "Check SSN '" & SSN & "' and try again . . ."
      Style = vbInformation + vbOKOnly
      Title = "SSN Not 9 Digits Error! . . ."
      MsgBox Msg, Style, Title
      CipherSSN = Null
   Else
      Do
         x = x + 1
         
         If Asc(Left(SSN, 1)) < 58 Then
            If (x Mod 2) = 0 Then
               Mask = 64
            Else
               Mask = 32
            End If
         Else
            If (x Mod 2) = 0 Then
               Mask = -64
            Else
               Mask = -32
            End If
         End If
         
         Build = Build & Chr(Asc(Mid(SSN, x, 1)) + Mask)
      Loop Until x = 9
      
      CipherSSN = Build
   End If
   
End Function[/blue]
[/li]
[li]Save the module then [blue]Alt + Q[/blue] to return to the module window.[/li][/ol]
This is it for the module. Don't do anything else with it!

Let me know if you were successful with this so we can move on to the form . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
I'm definitely NOT a VB programmer. I couldn't find a title that fit me, honestly. I do coding in Coldfusion & use MS Access as a backend database. Although I create a number of queries & tables, I've never had to create forms in Access before. I've learned everything on the fly, and really don't know the principles of programming. And no, I did not have html in the module. I thought I needed it to post it as code on this forum.

So if your patience is not completely gone...I have now created modCipher and it looks exactly like your code posted above.
 
OK Tototootoo . . .

For testing create a blank form:
[ol][li]From the forms window click [blue]New[/blue]. When the wizard starts select [blue]Design View[/blue].[/li]
[li]Save the form and give it a name but stay in design view.[/li]
[li]Click the properties toolbar button
Properties.BMP
to bring up the properties window (if its not already open).[/li]
[li]In the properties window click the [blue]Other[/blue] tab.[/li]
[li]Add a textbox to the form and set the name property to [blue]SSN[/blue] (no quotations).[/li]
[li]Add another textbox to the form and set the name property to [blue]Answer[/blue].[/li]
[li]Add a Command Button to the form and when the wizard starts click [blue]cancel[/blue].[/li]
[li]Make sure the buttons is selected then select the [blue]events[/blue] tab of the properties window.[/li]
[li]Put the cursor on the [blue]On Click[/blue] event line then click the three elipses
Elipses.BMP
just to the right.

If a [blue]Choose Builder[/blue] dialog opens select [blue]Code Builder[/blue] and click OK.[/li]
[li]Your now in the code module for the form and the cursor is in the click event of the button. Copy/paste the following where the cursor is in the event:
Code:
[blue]   Me!Answer = CipherSSN(Me!SSN)[/blue]
[/li]
[li][blue]Alt + Q[/blue] to return to form design view.[/li]
[li]Save & close the form[/li]
[li]Open the form[/li][/ol]
Enter an SSN in the SSN textbox and hit the button. The cypher should show in the answer textbox.

Enter the cypher in the SSN textbox and the answer should be the SSN . . .

You can now convert ssn's/ciphers back and forth giving you the power to hide your ssn's until you need to view the actual values . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Thank you so much! It works perfectly. I was also able to modify code you gave me previously to find if a record had already been entered and then go to that record.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top