Results 1 to 3 of 3

Thread: Convert text to only spaces (and back) No joke!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2013
    Posts
    27

    Convert text to only spaces (and back) No joke!

    Sounds impossible? Well, if you know how binary code, the extended ascii table and encodings work, my "trick" will be easy to understand:

    Every character in the text/string will be converted to an 8-bit binary extended ascii code. Then the binary code is converted to 2 different kinds of space characters. They will appear the same to the human eye, but one of them is the more unusual non-breaking space, but is part of any encoding based on ISO 8859-1/Latin-1.

    This should not be a replacement for encryption. But if used on encrypted text, you can then hide any encrypted strings making them difficult to find.

    The only limitation for this is the format of where you store the "hidden" text, it must allow the non-breaking space character(ascii 160).
    If you don't know how binary code works, that's fine, but note that the space string will be 8 times longer than the original string.

    Code:
    'SpaceHide and SpaceShow is the only functions that need to be called
    'The other functions are mostly to simplify testing and debugging
    Public Function SpaceHide(ByVal s As String) As String
        SpaceHide = Bin2Space(String2Bin(s))
    End Function
    Public Function SpaceShow(ByVal s As String) As String
        SpaceShow = Bin2String(Space2Bin(s))
    End Function
    Public Function String2Bin(ByVal e) As String
        Dim p, i, val, bin, out
        For p = 1 To Len(e)
            bin = ""
            val = Asc(Mid(e, p, 1))
            For i = (8 - 1) To 0 Step -1 'loop right to left for 8 bits
                If val And (2 ^ i) Then
                    bin = bin & "1"
                Else
                    bin = bin & "0"
                End If
            Next
            out = out & bin
        Next p
        String2Bin = out
    End Function
    Public Function Bin2Space(ByVal s As String) As String
        Dim bin As String
        bin = Replace(s, "0", Chr(32))
        bin = Replace(bin, "1", Chr(160))
        Bin2Space = bin
    End Function
    Public Function Space2Bin(ByVal s As String) As String
        Dim bin As String
        bin = Replace(s, Chr(32), "0")
        bin = Replace(bin, Chr(160), "1")
        Space2Bin = bin
    End Function
    Public Function Bin2String(ByVal lBin As String) As String
        'This is the only function that probably needs error handling,
        'depending on where the space string was stored it might get corrupted
        'Any error will return a string beginning with *ERROR* and a description
        Dim p, bp, dec, bit, out
        If Len(lBin) Mod 8 <> 0 Then
            Bin2String = "*ERROR* Length " & Len(lBin) & " not divisible by 8"
            Exit Function
        End If
        dec = 0
        For p = 1 To Len(lBin)
            bp = bp + 1
            bit = Mid(lBin, Len(lBin) - p + 1, 1) 'from right to left: len - position
            If Not (bit = "0" Or bit = "1") Then
                Bin2String = "*ERROR* Not 0/1: " & bit & " at pos " & p & " (right-to-left)"
                Exit Function
            End If
            dec = dec + (CByte(bit) * (2 ^ (bp - 1))) 'bp = position from left to right
            If p Mod 8 = 0 Then
                'We have the 8 bits. Convert to char and save, and reset dec and bp
                out = Chr(dec) & out 'store latest char first cause we're doing right to left
                dec = 0
                bp = 0
            End If
        Next p
        Bin2String = out
    End Function
    Example of a database table where the column Password is a decoy and the real passwords are stored in column Notes. Who can tell
    Attached Images Attached Images  

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,904

    Re: Convert text to only spaces (and back) No joke!

    Nice trick, but when you actually look at the data directly, for example using an HexEditor, you will see the difference between "20" and "A0" clearly.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2013
    Posts
    27

    Re: Convert text to only spaces (and back) No joke!

    Of course, even the hidden data has to be stored somewhere. You can't hide it completely..... or can you?? Hint: alternate data stream ;-)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width