New
#1
TextHider: Make text invisible + hidden
InformationA standalone program(EXE) is available at post #5, followed by updates in later posts.
To "hide" text means to transform it to a coded set of spaces so it looks invisible.
To "store it invisibly in a file" means to not actually store the "hidden" text in a file, but in a property for a file, so it appears hidden (post #8, version 2 of the program)
There's also an option to set a password which will transform the text into what looks like random garbage before it's converted to spaces
The original post was about a VB-script program that was limited and not practical to use. However, it includes a description of the first version of the program, so I've kept that post. Click the button below to see it:
This is part of an project I'm working on, but I've made a simplified VBscript version that maybe someone finds useful, interesting or maybe even educational
Enter some text, add a password(optional) and you'll receive an "empty" string to store somewhere. Well it's not an empty string, it's spaces, 2 different types of space characters. If a password is entered the text will first be modified to a completely different text string(depending on the password). Then the text will be converted to binary code(0's and 1's) and then they will be replaced with space and the web version of space, chr 160, the non-breaking space, which you can store in most programs. If you set a password and you don't enter the exact same password(case sensitive) when you want the "hidden" text back, not even I can help you. You'll only get something that looks like random characters.
Because of VBscript and input boxes restrictions I've set a maximum length of 30 in this version. Because each char will be transformed to 8 "spaces" because of the binary conversion.
Questions? Just ask. Oh, and when you "hide" some text it will also do a test to see that the "hidden" text could be unhidden successfully. If you enter a non-ascii char like β it will fail.
If anyone wants more comments in the code, let me know.
If you use this code in VB or VBA, you can skip the input boxes and the 30 char limit and "hide" an entire document content, for example a notepad document. If someone opens the document it will appear empty at first. If checked in a better editor they will see only two types of characters. If they figure out it could be binary and tries to convert it, they will only see what appears like random crap. Assuming you set a password. Even if they find the source code they still need the password.
Copy this to a new file, for example HidePassword.vbs
Then copy the HidePassword.vbs file and name it for example UnhidePassword.vbs Then edit that file and replace the lines between the ****************** lines with these:Script:
pgmName = "Password hide"
MIN_ASC = 32
MAX_ASC = 255
NO_OF_CHARS = MAX_ASC - MIN_ASC + 1
'********************************************************************************************
txt = inputbox("Enter text to 'hide'" & Chr(10) & "(max 30 chars)", pgmName)
if len(txt) > 30 then
msgbox "Text is longer than 30 chars"
Wscript.Quit
end if
key = inputbox("Enter password", pgmName)
hdn = hide(ChangeText(txt,key))
back = UnChangeText(unhide(hdn),key)
if txt = back then
dummy = inputbox("Success!", pgmName,hdn)
else
dummy = inputbox("FAIL! The text probably contains non-ascii characters", pgmName,back)
end if
'********************************************************************************************
Function ChangeText(p1, p2)
if p2="" then ChangeText=p1: exit function
pwd = p2
chkSum = 0
keyPos = 0
e = ""
For keyPos = 1 To Len(pwd)
chkSum = chkSum + Asc(Mid(pwd, keyPos, 1)) * keyPos
Next
keyPos = 0
For p = 1 To Len(p1)
c = Asc(Mid(p1, p, 1))
keyPos = keyPos + 1
If keyPos > Len(pwd) Then keyPos = 1
k = Asc(Mid(pwd, keyPos, 1))
c = ChangeAsc(c, k)
c = ChangeAsc(c, chkSum)
c = ChangeAsc(c, k * Len(pwd))
c = ChangeAsc(c, chkSum * k)
c = ChangeAsc(c, p * k)
c = ChangeAsc(c, Len(pwd) * p)
e = e & Chr(c)
Next
ChangeText = e
End Function
Function UnChangeText(p1, p2)
if p2="" then UnChangeText=p1: exit function
pwd = p2
chkSum = 0
keyPos = 0
e = ""
For keyPos = 1 To Len(pwd)
chkSum = chkSum + Asc(Mid(pwd, keyPos, 1)) * keyPos
Next
keyPos = 0
For p = 1 To Len(p1)
c = Asc(Mid(p1, p, 1))
keyPos = keyPos + 1
If keyPos > Len(pwd) Then keyPos = 1
k = Asc(Mid(pwd, keyPos, 1))
'Opposite order of ChangeAsc calls in ChangeText
'and minus(-) for the 2nd parameter
c = ChangeAsc(c, -(Len(pwd) * p))
c = ChangeAsc(c, -(p * k))
c = ChangeAsc(c, -(chkSum * k))
c = ChangeAsc(c, -(k * Len(pwd)))
c = ChangeAsc(c, -chkSum)
c = ChangeAsc(c, -k)
e = e & Chr(c)
Next
UnChangeText = e
End Function
Function ChangeAsc(p1, p2)
'Move the Asc value so it stays inside interval MIN_ASC and MAX_ASC
a = p1
mLvl = p2
mLvl = mLvl Mod NO_OF_CHARS
a = a + mLvl
If a < MIN_ASC Then
a = a + NO_OF_CHARS
ElseIf a > MAX_ASC Then
a = a - NO_OF_CHARS
End If
ChangeAsc = a
End Function
Function hide(param)
Dim p, i, val, bin, out
For p = 1 To Len(param)
bin = ""
val = asc(Mid(param, p, 1))
For i = (8 - 1) To 0 Step -1 'right to left
If val And (2 ^ i) Then
bin = bin & "1"
Else
bin = bin & "0"
End If
Next
out = out & bin
Next
out = Replace(out, "0", Chr(32))
out = Replace(out, "1", Chr(160))
hide = out
End Function
Function unhide(param)
Dim p, bp, dec, bit, bin, out
bin = param
bin = Replace(bin, Chr(32), "0")
bin = Replace(bin, Chr(160), "1")
If Len(bin) Mod 8 <> 0 Then
unhide = "*ERROR* Length of hidden text is not correct"
Exit Function
End If
dec = 0
For p = 1 To Len(bin)
bp = bp + 1
bit = Mid(bin, Len(bin) - p + 1, 1) 'from right to left: len - position
If Not (bit = "0" Or bit = "1") Then
unhide = "*ERROR* Invalid char: " & bit
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
unhide = out
End Function
Happy "hiding"Code:hdn = inputbox("Enter text to unhide", pgmName) key = inputbox("Enter password", pgmName) back = UnChangeText(unhide(hdn),key) dummy = inputbox("Hidden text",pgmName,back)
Last edited by Tookeri; 13 Nov 2014 at 17:41. Reason: info about exe program in post 5 & 8