Assuming the algorithm I posted is correct...
edit - Wow!Code:Dim buf(255) As Byte 'test buffer 'generate all possible byte values for testing For bv As Integer = 0 To 255 buf(bv) = CByte(bv) Next Dim eqAsByte As Byte = Asc("=") Dim critCH() As Byte = New Byte() {0, _ Asc(ControlChars.Tab), _ Asc(ControlChars.Lf), _ Asc(ControlChars.Cr), _ eqAsByte} Dim encodedBuf As New List(Of Byte) 'encode For Each byt As Byte In buf 'fetch the character Dim addByte As Integer If Not critCH.Contains(byt) Then 'is it critical 'no addByte = byt + 42 Else 'yes, is a critical? character encodedBuf.Add(eqAsByte) 'add equal sign to output addByte = byt + 64 End If addByte = addByte And 255 encodedBuf.Add(CByte(addByte)) Next Dim outBuf() As Byte = encodedBuf.ToArray 'Debug.WriteLine(System.Text.ASCIIEncoding.ASCII.GetChars(encodedBuf.ToArray))




Reply With Quote