i want this to be able to save the encrypted data in the table but then when the form is opened have the data decrypted to be shown in the form.
well i here is what i have on the form that the data is typed in:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
bWasNewRecord = Me.NewRecord
Call AuditEditBegin("EmpInfo", "audTmpEmpInfo", "ID", Nz(Me.ID, 0), bWasNewRecord)
If Not IsNull(SSN) Then
Call Enc("SSN")
End If
End Sub
Private Sub Form_Current()
If Not IsNull(SSN) Then
Call Enc("SSN")
End If
End Sub
and here is the enc/dec modual:
Code:
Dim sSecretData
Dim sCipherText
Dim capEData
Dim sPlainText
Dim key
Function Enc(ByVal SSN As String) As String
sSecretData = "SSN"
key = "Super duper password"
' Build up the key
Set capEData = CreateObject("CAPICOM.EncryptedData.1")
capEData.Algorithm = 3 'Use 3DES
capEData.SetSecret key
capEData.Content = sSecretData
sCipherText = capEData.Encrypt
Beep
MsgBox "Original data:" & sSecretData, vbOKOnly, ""
MsgBox "Encrypted data: " & sCipherText, vbOKOnly, ""
End Function
Function Dec(ByVal SSN As String) As String
key = "Super duper password"
capEData.Algorithm = 3
capEData.SetSecret key
capEData.Decrypt sCipherText
sPlainText = capEData.Content
MsgBox "Recoverd data: " & sPlainText, vbOKOnly, ""
End Function
after it saves it tells me from the msgbox that i has been encrypted and what it has been encrypted too but when i look in the table part it is not encrypted it still shows the original data