Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

VERY weird encoding/decoding.


  • Please log in to reply

#1
IO-error

IO-error

    Member

  • Member
  • PipPipPip
  • 276 posts
Hi all.
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?
  • 0

Advertisements


#2
MaverickSidewinder

MaverickSidewinder

    Member

  • Member
  • PipPipPip
  • 257 posts
Well, an encoder isn't much with a decoder...but if the bet was only to make an encoder then you won yes.

I have tried to make an encryption script in C++ though, I know some VB. Everything looks good from here, don't know what could be the problem.

not very fond of the "opentextfile" part...

good luck though
  • 0

#3
IO-error

IO-error

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 276 posts
I made a decoder to go with it, but the unexpected thing is, that it will have to decode a couple of times before it's completly decoded.

Example from the script output:
When I want to encode "a" I get this string:
AAA×gpko×pko×hqwe×××hpko×qwe××pko××

When I try to decode that once, I get:

gtthy××hty×t×

When I run the decode script again, it will give me:

gtr×nt×

Then I get:

hnt×

And only after that, I get the string I wanted to encode...

So that's my problem, why does it do a quadrouple encoding, even though I'm not asking for it?
On the other hand, it IS kinda save.


And the bet was that I could build a decoder that automatically decodes the part with 1 script run...
So, still no problem, because I can build a loop into it.

And what's wrong with the opentextfile method?

Edited by IO-error, 22 November 2006 - 03:08 AM.

  • 0

#4
mpfeif101

mpfeif101

    Member 1K

  • Retired Staff
  • 1,411 posts
I'm not good at vbs, but couldn't you just do a loop 4 times? Seems like an easy way to get around it :whistling:
  • 0

#5
IO-error

IO-error

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 276 posts
Yeah, I said I was planning that already.
Well, the script is already complete, the lop included. The project closed, now I'm going to use that project for my new project, an instant messenger on VBS.

Hehe, that's my last idea that I want to make, then I'm heading to C++.

The problem was that the Encoding script is making no sense to me... it's encoding it and then encoding every letter it found... that's the problem.
  • 0

#6
Granz00

Granz00

    Member

  • Member
  • PipPipPip
  • 226 posts
Yay I think I know the problem. I don't know the techniques you are using, but it seems to be a problem with logic. Here is an example;

If a = bcb and b = cdc and c = ded and so on.
a would convert to bcb
bcb is then converted to cdcccdc
Then that is converted.

So if I'm correct, the letters h, t, n, & x will be encoded into what their code is. That might be why you have to decode it 4 times since you have 4 letters as your encoder.
If not, then hopefully this helps with figuring out your problem.
  • 0

#7
IO-error

IO-error

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 276 posts
Yep, that is the problem.
Or actually, a handy bug.
I used it as decoding for something of my gameserver.
And it was a good thing I did that, my server got hacked and they downloaded the files. Without the decoding script, I would have lost my AI scripts for a UT2004 server. Advanced self-bred scripts mehehehe...

Anywayz, this is just one of the bugs in the whole VBS I guess.
  • 0

#8
IO-error

IO-error

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 276 posts
Ok, back to this bug here...

I didn't script the new value for an ×, it's a char I wanted to use to encode the file. It's made by using CTRL+ALT+=.
So it will never try to encode that character. So if you use logics, the sequence will not change, it will not double encode, because I didn't put a loop in the encoding.

Edited by IO-error, 11 January 2007 - 08:17 AM.

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP