Jump to content

Code Decoder


Recommended Posts

Well, I made a code using numbers:

1=A

2=B

3=C

4=D

5=E

6=F

7=G

8=H

9=I

10=J

11=K

12=L

13=M

14=N

15=O

16=P

17=Q

18=R

19=S

20=T

21=U

22=V

23=W

24=X

25=Y

26=Z

| is the seperator from letters

Space is the word seperator

This is how it works:

Code: 8|9 13|25 14|1|13|5 9|19

English: My name is

I'm trying to write a decoder trying to use an inputbox, and stringsplit and when it finds a string, it adds it to a blank new message

$String = InputBox("Simple Decoder", "What is the message you want to decode?")
$StringSplit = StringSplit($String, "|")

But Then I get stuck after that, I debugged it with a message box but it didn't help. Any Ideas? Thanks! ;):)

Edited by JustinReno
Link to comment
Share on other sites

I did above, as you see I got stuck with debugging.

Ahh. You were trying to see results in $StringSplit with a MsgBox()? That doesn't work because StringSplit() returns an array. The easiest way to check those is just put #include <array.au3> at the top of your script and then use _ArrayDisplay():

#include <array.au3>

$String = InputBox("Simple Decoder", "What is the message you want to decode?")
$StringSplit = StringSplit($String, "|")
_ArrayDisplay($StringSplit, "Debug: $StringSplit")

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

hey we use to use that in school when i was a kid.. :)

Thanks for it, but it seems a little inconvientent to show the results in an array.

Array's are cool, im still playing and learning about them but they really do help and for something like this they would be perfect.

and ya stringsplit creates an array, you can fully read the array or write to one using loops without to much trouble, if you need to do it a lot you could create a function for it.

Link to comment
Share on other sites

Instead of 1=A, 2=B &etc. why didn't you just use

For $i = 65 To 90
   $Out  $i-64 & "=" & Chr($i)
Next

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

seems simple enough.

$input = InputBox("Encoded","Enter the code")
$output = ""

While StringLen($input) > 0
    Select
        Case StringLeft($input,1) = " "
            $output &= " "
            $input = StringTrimLeft($input,1)
        Case Number(StringLeft($input,2)) <> Number(StringLeft($input,1))
            $output &= Chr(96+Number(StringLeft($input,2)))
            $input = StringTrimLeft($input,2)
        Case Number(StringLeft($input,1))
            $output &= Chr(96+Number(StringLeft($input,1)))
            $input = StringTrimLeft($input,1)
        Case StringLeft($input,1) = "|"
            $input = StringTrimLeft($input,1)
    EndSelect
WEnd

MsgBox(0,"Decoded",$output)
Link to comment
Share on other sites

Cool! Thanks.

I didn't get far on the Encoder, I'm confused with StringLen/TrimLeft. Stuff like that.

BAsically I copied the decoder code to another file and switched this: when space is there it turns it into |

I'm not very good using string functions. Any help would be appreciated.

Link to comment
Share on other sites

$g_input = InputBox("Input","Enter the message to encode.")
$input = StringLower($g_input)
$output = ""

While StringLen($input) > 0
    Select
        Case StringLeft($input,1) = " "
            $output &= " "
            $input = StringTrimLeft($input,1)
        Case StringLeft($input,2) <> StringLeft($input,1) & " "
            $output &= Asc(StringLeft($input,1))-96 & "|"
            $input = StringTrimLeft($input,1)
        Case StringLeft($input,1)
            $output &= Asc(StringLeft($input,1))-96
            $input = StringTrimLeft($input,1)
    EndSelect
WEnd
$output = StringTrimRight($output,1)
MsgBox(0,"Encoded",$output)

EDIT:

The old code was bugged with extra "|". Fixed.

Edited by aslani

[font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...