Sign in to follow this  
Followers 0
FinalVersion

Reverse This Process

4 posts in this topic

#1 ·  Posted (edited)

Basically I want to reverse this.

Global $EC
    _FileReadToArray(@ScriptDir & "\" & $vDataFile, $EC)
    Global $EL[$EC[0]]
    Global $vLetter, $vCString

    For $i = 1 To $EC[0]
        $EL[$i - 1] = StringTrimLeft($EC[$i], "2")
    Next

    $sString = StringSplit($sString, "", 2)

    ; Huge switch statement, requires less UDF's.
    For $vLetter In $sString
        Select
            Case $vLetter = "a"
                $vCString = $vCString & $EL[0]
            Case $vLetter = "b"
                $vCString = $vCString & $EL[1]
            Case $vLetter = "c"
                $vCString = $vCString & $EL[2]
            Case $vLetter = "d"
                $vCString = $vCString & $EL[3]
            Case $vLetter = "e"
                $vCString = $vCString & $EL[4]
            Case $vLetter = "f"
                $vCString = $vCString & $EL[5]
            Case $vLetter = "g"
                $vCString = $vCString & $EL[6]
            Case $vLetter = "h"
                $vCString = $vCString & $EL[7]
            Case $vLetter = "i"
                $vCString = $vCString & $EL[8]
            Case $vLetter = "j"
                $vCString = $vCString & $EL[9]
            Case $vLetter = "k"
                $vCString = $vCString & $EL[10]
            Case $vLetter = "l"
                $vCString = $vCString & $EL[11]
            Case $vLetter = "m"
                $vCString = $vCString & $EL[12]
            Case $vLetter = "n"
                $vCString = $vCString & $EL[13]
            Case $vLetter = "o"
                $vCString = $vCString & $EL[14]
            Case $vLetter = "p"
                $vCString = $vCString & $EL[15]
            Case $vLetter = "q"
                $vCString = $vCString & $EL[16]
            Case $vLetter = "r"
                $vCString = $vCString & $EL[17]
            Case $vLetter = "s"
                $vCString = $vCString & $EL[18]
            Case $vLetter = "t"
                $vCString = $vCString & $EL[19]
            Case $vLetter = "u"
                $vCString = $vCString & $EL[20]
            Case $vLetter = "v"
                $vCString = $vCString & $EL[21]
            Case $vLetter = "w"
                $vCString = $vCString & $EL[22]
            Case $vLetter = "x"
                $vCString = $vCString & $EL[23]
            Case $vLetter = "y"
                $vCString = $vCString & $EL[24]
            Case $vLetter = "z"
                $vCString = $vCString & $EL[25]
            Case $vLetter = "0"
                $vCString = $vCString & $EL[26]
            Case $vLetter = "1"
                $vCString = $vCString & $EL[27]
            Case $vLetter = "2"
                $vCString = $vCString & $EL[28]
            Case $vLetter = "3"
                $vCString = $vCString & $EL[29]
            Case $vLetter = "4"
                $vCString = $vCString & $EL[30]
            Case $vLetter = "5"
                $vCString = $vCString & $EL[31]
            Case $vLetter = "6"
                $vCString = $vCString & $EL[32]
            Case $vLetter = "7"
                $vCString = $vCString & $EL[33]
            Case $vLetter = "8"
                $vCString = $vCString & $EL[34]
            Case $vLetter = "9"
                $vCString = $vCString & $EL[35]
            Case $vLetter = " "
                $vCString = $vCString & $EL[36]
        EndSelect

    Next

DataFile

a=5027
b=0675
c=1635
d=9564
e=5628
f=7143
g=2047
h=3454
i=1867
j=8896
k=6761
l=6456
m=3425
n=7561
o=4752
p=9471
q=1534
r=7616
s=2561
t=0610
u=0518
v=8645
w=2387
x=5432
y=5413
z=1556
0=6654
1=6467
2=6554
3=7635
4=2556
5=1324
6=3242
7=3453
8=8382
9=1343
 =2186

I know what I want to do (which is reverse this process) but I don't know how to explain it. I guess instead of changes the alaphabet to the random numbers, change the 4 numbers back into letters.

Example:

If I changed the String to "50270675" it would give me "ab".

Edited by FinalVersion

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1 Use a loop and StringMid to build an array of 4 character substrings from your input string.

(You basically have a running counter that increments by 4 and a constant StringMid 'count' parameter of 4.)

2 Use a loop to compare each substring to your character equivalents.

(You'll have to compare each substring to every character value until you get a match.)

3 Build the output string based on the comparison results.

(Just concatenate the resultant character you get from your comparisons into an output string.)

Edited by omikron48

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You are trying to build a textencryptor without algorithms.

I also did this. The code is not too pretty coz i had lil time to do it, but here's how i did it:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUICloseOnESC", 1); ESC to exit
local $output
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("mijk's converter", 915, 114, 340, 383, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Convert:", 8, 16, 44, 17)
$txtConvert = GUICtrlCreateInput("", 56, 16, 777, 21)
$Label2 = GUICtrlCreateLabel("Reveal:", 8, 64, 41, 17)
$txtReveal = GUICtrlCreateInput("", 56, 64, 777, 21)
$btnConvert = GUICtrlCreateButton("Convert", 840, 16, 73, 25, $WS_GROUP)
$btnReveal = GUICtrlCreateButton("Reveal", 840, 64, 73, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        ;Case $nMsg = -3 
    ;       Exit
        case $btnConvert
            $output = stringregexpreplace(guictrlread($txtconvert),"a","|421|")
            guictrlsetdata($txtconvert, $output)
            $output =  stringregexpreplace(guictrlread($txtconvert),"b","|0a39|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"c","|fb09|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"d","|bb124|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"e","|000a|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"f","|0897|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"g","|eb31|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"h","|gg44|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"i","|528a|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"j","|~23|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"k","|=+8|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"l","|99=|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"m","|CC54|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"n","|C777|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"o","|D12|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"p","|15A|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"q","|558|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"r","|019|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"s","|059|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"t","|0009|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"u","|0fda9|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"v","|F09A|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"w","|B09V|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"x","|A09I|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"y","|Z09|")
            guictrlsetdata($txtconvert, $output)
            $output = stringregexpreplace(guictrlread($txtconvert),"z","|08U|")
            guictrlsetdata($txtconvert, $output)
            
        case $btnReveal
            
            $output  = stringreplace(guictrlread($txtreveal),"|421|", "a")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|0a39|","b")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|fb09|","c")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|bb124|","d")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|000a|","e")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|0897|","f")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|eb31|","g")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|gg44|","h")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|528a|","i")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|~23|","j")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|=+8|","k")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|99=|","l")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|CC54|","m")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|C777|","n")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|D12|","o")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|15A|","p")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|558|","q")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|019|","r")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|059|","s")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|0009|","t")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|0fda9|","u")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|F09A|","v")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|B09V|","w")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|A09I|","x")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|Z09|","y")
            guictrlsetdata($txtreveal, $output)
            $output = stringreplace(guictrlread($txtreveal),"|08U|","z")
            guictrlsetdata($txtreveal, $output)
    EndSwitch
WEnd

Edit : note you should not use StringRegexpReplace but only "Stringreplace"... forgot to edit that in this example.

Edited by notsure

Share this post


Link to post
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
Sign in to follow this  
Followers 0