Here's my situation and I'm as stumbled as the most of you when you hear this out.
The deal is, I made a script to encode some string.
It's working like this:
=============================
'Init writing.
Set FSO = CreateObject("Scripting.FileSystemObject")
Set document = FSO.OpenTextFile("Encode-test.text", 2, True)
input = inputbox("")
input = replace(input, "a", "hnt×")
input = replace(input, "b", "htn×")
input = replace(input, "c", "tnh×")
'Imagine this script holding the complete alfabet to replace with 3 letter string, ending with × (CTRL+ALT+=)
document.write("AAA×"&input)
=============================
Then there is the decoding part...
=============================
'Init reading.
Set FSO = CreateObject("Scripting.FileSystemObject")
Set document = FSO.OpenTextFile("Encode-test.text", 1, True)
'Read
input = document.ReadAll
'Decode..
input = replace(input, "hnt×", "a")
input = replace(input, "htn×", "b")
input = replace(input, "tnh×", "c")
'Init/Do writing.
Set document = FSO.OpenTextFile("Encode-test.text", 2)
document.write(input)
=============================
Now here is my problem:
When the input is "a", I get an enormously long string.
AAA×gpko×pko×hqwe×××hpko×qwe××pko××
When I ask my logics, I'm not gonna get an answer.
Some classmates are watching weird at how it's possible that there are 4-letter strings in the complete string... and that there are so many letters, instead of just "hnt×"
The only good thing about this is that I had a bet with a friend that I could make an encoder that is EXTREMELY hard to crack, EVEN with source code... I guess I won that bet, right?
The bad thing about it is that the decode-script has to be run 4 or 5 times to completly decode the text.
Is there an explanation for this behaviour of VBS?