Hello everyone, I have been lurking over the forums for some time now, not posting. I have decided to make my own contribution. I don't know if anyone else has done this before or whatever, and I don't know how strong it is..
Code:
Public Function EncryptF(ByVal Password As String, ByVal Text As String) As String
Dim Temp As Integer
Dim i As Long
If (Len(Password) < Len(Text)) Then
Temp = Len(Text) / Len(Password)
For i = 1 To Temp + 1
Password = Password & Password
Next i
End If
EncryptF = vbNullString
For i = 1 To Len(Text)
Temp = Asc(Mid(Text, i, 1)) + Asc(Mid(Password, i, 1))
EncryptF = EncryptF & Chr(Temp)
Next i
Exit Function
ErrorH:
MsgBox ErrHandle, vbCritical, "Error"
End Function
Public Function DecryptF(ByVal Password As String, ByVal Text As String) As String
On Error GoTo ErrorH
Dim Temp As Integer
Dim i As Long
If (Len(Password) < Len(Text)) Then
Temp = Len(Text) / Len(Password)
For i = 1 To Temp + 1
Password = Password & Password
Next i
End If
DecryptF = vbNullString
For i = 1 To Len(Text)
Temp = Asc(Mid(Text, i, 1)) - Asc(Mid(Password, i, 1))
DecryptF = DecryptF & Chr(Temp)
Next i
Exit Function
ErrorH:
MsgBox ErrHandle, vbCritical, "Error"
End Function
Private Function ErrHandle() As String
If (Err.Description <> "") Then
ErrHandle = "An error has occured!" & vbNewLine & Err.Number & ") " & Err.Description
End If
End Function
The source for the Module is above, and there should be an attachment, with it in a module.
Credits go to me!
Warning: Attachment is out of date.
Edit: Oh I forgot to say.. it doesn't work with special characters!
Last edited by Vanasha; Sep 13th, 2007 at 10:58 AM.
Reason: Code update