CODIGO:
Código vb:
Ver original
Option Explicit Private Const MODULE_NAME As String = "mRafael" Public Const LlaveMaster As String = "xm8CLseixmy416hTH" Public Const IDSEP As String = "¦" Global Const ENCRYPT As Integer = 0 Global Const DECRYPT As Integer = 1 Public Function EncryptString(UserKey As String, text As String, Action As Single) As String Dim UserKeyX As String Dim temp As Integer Dim Times As Integer Dim i As Integer Dim j As Integer Dim n As Integer Dim rtn As String '//Get UserKey characters n = Len(UserKey) ReDim UserKeyASCIIS(1 To n) For i = 1 To n UserKeyASCIIS(i) = Asc(Mid$(UserKey, i, 1)) Next '//Get Text characters ReDim TextASCIIS(Len(text)) As Integer For i = 1 To Len(text) TextASCIIS(i) = Asc(Mid$(text, i, 1)) Next '//Encryption/Decryption If Action = ENCRYPT Then For i = 1 To Len(text) j = IIf(j + 1 >= n, 1, j + 1) temp = TextASCIIS(i) + UserKeyASCIIS(j) If temp > 255 Then temp = temp - 255 End If rtn = rtn + Chr$(temp) Next ElseIf Action = DECRYPT Then For i = 1 To Len(text) j = IIf(j + 1 >= n, 1, j + 1) temp = TextASCIIS(i) - UserKeyASCIIS(j) If temp < 0 Then temp = temp + 255 End If rtn = rtn + Chr$(temp) Next End If '//Return EncryptString = rtn End Function