Here's a simple XOR encryption algorithm that I use now and then. This code has been tested:<br>
<br>
Public Function Encrypt(UnEncrypted As String, ByVal Key As String) As String<br>
'Simple XOR Incryption With Key<br>
'This function takes two paramaters. One is the Encrypted or Non-Encrypted string,<br>
'the other is the Key to encrypt or un-encrpyt with. It returns the encrypted or<br>
'un-encrypted string result. EncryptedString = Encrypt(StringToEncrypt, EncryptionKey).<br>
'Then call the function again to decrypt the string<br>
'RealString = Encrypt(EncryptedSting, EncryptionKey).<br>
'<br>
'You must use the same key to decrypt the string as you do to encrypt it.<br>
'<br>
'Sample usage:<br>
'<br>
' strString = Encrypt("January 1, 2000", "ABC"

<br>
' Debug.Print Encrypt(strString, "ABC"

<br>
'<br>
<br>
Dim lngOffset As Long<br>
<br>
Do Until Len(Encrypt) = Len(UnEncrypted)<br>
For lngOffset = 1 To Len(Key)<br>
If Len(Encrypt) = Len(UnEncrypted) Then Exit For<br>
Encrypt = Encrypt & Chr(Asc(Mid(UnEncrypted, Len(Encrypt) + 1, 1)) Xor Asc(Mid(Key, lngOffset, 1)))<br>
Next lngOffset<br>
Loop<br>
End Function<br>
<br>
I also found some code that does RLE (Run Length Encoding) in VB. I can't vouch for this code as I have not used it or tested it. Use this code at your own risk. Having said that, here's the code:<br>
<br>
Option Explicit<br>
<br>
Public Sub Main()<br>
Dim TempArr() As Byte<br>
Dim TempStr As String<br>
TempStr = "TTTTHHHHIIIISSSS a Test"<br>
RLECompress TempStr, TempArr<br>
TempStr = TempArr<br>
TempStr = RLEUncompress(TempArr)<br>
End Sub<br>
<br>
Public Sub RLECompress(StrToCompress As String, ByteArr() As Byte)<br>
Dim TempArr() As Byte<br>
Dim I As Integer<br>
Dim ByteCnt As Byte<br>
Dim PrevAdded As Boolean<br>
TempArr = StrConv(StrToCompress, vbFromUnicode)<br>
ReDim ByteArr(0)<br>
ByteArr(0) = TempArr(0)<br>
For I = 1 To UBound(TempArr)<br>
If TempArr(I) = TempArr(I - 1) Then<br>
ByteCnt = I<br>
Do Until (TempArr(ByteCnt) <> TempArr(I - 1)) Or (ByteCnt - (I - 1) = 254)<br>
ByteCnt = ByteCnt + 1<br>
If ByteCnt > UBound(TempArr) Then Exit Do<br>
Loop<br>
If UBound(ByteArr) = 0 Then<br>
ReDim Preserve ByteArr(UBound(ByteArr) + 1)<br>
ElseIf PrevAdded = False Then<br>
ReDim Preserve ByteArr(UBound(ByteArr) + 2)<br>
End If<br>
ByteArr(UBound(ByteArr) - 1) = (ByteCnt - (I - 1))<br>
ByteArr(UBound(ByteArr)) = TempArr(I)<br>
I = ByteCnt - 1<br>
PrevAdded = False<br>
Else<br>
ReDim Preserve ByteArr(UBound(ByteArr) + 2)<br>
ByteArr(UBound(ByteArr) - 1) = 1<br>
ByteArr(UBound(ByteArr)) = TempArr(I)<br>
PrevAdded = True<br>
End If<br>
Next I<br>
End Sub<br>
<br>
Public Function RLEUncompress(ByteArr() As Byte)<br>
Dim I As Integer<br>
For I = 0 To UBound(ByteArr) Step 2<br>
RLEUncompress = RLEUncompress & String(ByteArr(I), Chr(ByteArr(I + 1)))<br>
Next I<br>
End Function<br>
<br>
<p>Steve Meier<br><a href=mailto:sdmeier@jcn1.com>sdmeier@jcn1.com</a><br><a href= > </a><br>