Пример простейшего шифрования... [VB src]
Код:
Private Function STR_TO_ARRAY(Str As String) As String()
Dim tmpArray() As String
ReDim tmpArray(0 To Len(Str))
For i = 0 To Len(Str)
tmpArray(i) = Mid(Str, InStr(Str, Str) + i, 1)
Next i
STR_TO_ARRAY = tmpArray
End Function
Private Function ARRAY_TO_STR(Str() As String) As String
Dim tmpArray() As String
Dim tmpStr As String
ReDim tmpArray(LBound(Str) To UBound(Str))
tmpArray = Str
For i = LBound(Str) To UBound(Str)
If i = LBound(Str) Then
tmpStr = tmpArray(i)
Else
tmpStr = tmpStr & tmpArray(i)
End If
Next i
ARRAY_TO_STR = tmpStr
End Function
Private Function ARRAY_TO_ASC(Str() As String) As String()
Dim tmpArray() As String
Dim tmpAsc() As String
ReDim tmpArray(LBound(Str) To UBound(Str))
ReDim tmpAsc(LBound(Str) To UBound(Str))
tmpArray = Str
For i = LBound(Str) To (UBound(Str) - 1)
tmpAsc(i) = Asc(tmpArray(i))
Next i
ARRAY_TO_ASC = tmpAsc
End Function
Private Function Encrypt(Str As String) As String
Dim tmpArray() As String
Dim tmpAsc() As String
Dim tmpFin As String
tmpArray() = STR_TO_ARRAY(Str)
tmpAsc() = ARRAY_TO_ASC(tmpArray())
For i = LBound(tmpAsc()) To (UBound(tmpAsc()) - 1)
If i = LBound(tmpAsc()) Then
tmpFin = Chr(tmpAsc(i) - 1)
Else
tmpFin = tmpFin & Chr((tmpAsc(i) - 1))
End If
Next i
Encrypt = tmpFin
End Function
Private Function Decrypt(Str As String) As String
Dim tmpArray() As String
Dim tmpAsc() As String
Dim tmpFin As String
tmpArray() = STR_TO_ARRAY(Str)
tmpAsc() = ARRAY_TO_ASC(tmpArray())
For i = LBound(tmpAsc()) To (UBound(tmpAsc()) - 1)
If i = LBound(tmpAsc()) Then
tmpFin = Chr(tmpAsc(i) + 1)
Else
tmpFin = tmpFin & Chr((tmpAsc(i) + 1))
End If
Next i
Decrypt = tmpFin
End Function