VB Code:
Private Function InvertString(sT As String) As String Dim sTT As String For I = Len(sT) To 1 Step -1 sTT = sTT & Mid(sT, I, 1) Next InvertString = sTT End Function Private Function Encrypt(sT As String, sKey As String) As String Dim sEncrypted As String Dim keyCount As Integer sT = InvertString(sT) sKey = InvertString(sKey) keyCount = 1 For I = 1 To Len(sT) sEncrypted = sEncrypted & Chr(Asc(Mid(sT, I, 1)) + Mid(sKey, keyCount, 1)) keyCount = keyCount + 1 If keyCount > Len(sKey) Then keyCount = 1 Next Encrypt = sEncrypted End Function Private Function Decrypt(sT As String, sKey As String) As String Dim sDecrypted As String Dim keyCount As Integer sKey = InvertString(sKey) keyCount = 1 For I = 1 To Len(sT) sDecrypted = sDecrypted & Chr(Asc(Mid(sT, I, 1)) - Mid(sKey, keyCount, 1)) keyCount = keyCount + 1 If keyCount > Len(sKey) Then keyCount = 1 Next Decrypt = InvertString(sDecrypted) End Function
Just use, Encrypt() And Decrypt() - remember to pass the same key!!




Reply With Quote