Jump to content
Sign in to follow this  
seandisanti

Another stupid little program

Recommended Posts

seandisanti

This guy at work asked me to make him a simple encryption program for a quick encrypt/decrypt that he could type into, then copy encrypted text, or paste in encrypted text (generated by someone else using the script). because he wanted to copy and paste back and forth, i was restricted to encryptions that didn't create any non printable characters. I took the easy way out because 'real' encryption wasn't really necessary, and just converted the ascii value of characters to base-3. a password is required to decrypt, and it's checked against a saved password. the first time that you run the program, it will ask for what password to use, and store it in your mydocs folder with the filename EP. One thing that i realized after i sent it to him was that it starts off in 'encrypt' mode, so if you're just opening it to decrypt, click the button before pasting into the edit box. posting it incase anyone wants stupid encryption, or an example of converting decimal to a number system with an uncommon radix.

#include<guiconstants.au3>
Opt("GUIOnEventMode",1)
If FileExists(@MyDocumentsDir & "\ep") Then
    Global $pass = FileReadLine(@MyDocumentsDir & "\ep")
Else
    Global $pass = InputBox("Password Not Saved","Enter password you would like to use to decrypt text")
    FileWriteLine(@MyDocumentsDir & "\ep",$pass)
EndIf
Global $gui = GUICreate("blah",300,300)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
Global $tb = GUICtrlCreateEdit("",10,10,280,250,BitOR($ES_MULTILINE,$ES_WANTRETURN,$ES_AUTOVSCROLL))
Global $btn = GUICtrlCreateButton(".",10,270,280)
GUICtrlSetOnEvent($btn,"encdec")
GUISetState()
Global $ed = 0
while 1
    sleep(100)
WEnd
Func CloseClicked()
    Exit
EndFunc
Func encdec()
    Select
    Case $ed = 1
        decfunc()
        $ed = 0
    case Else
        encfunc()
        $ed = 1
    EndSelect
EndFunc
Func encfunc()
    $contents = GUICtrlRead($tb)
    Global $new = ""
    For $a = 1 to StringLen($contents)
        $power = 4  
        $number = asc(StringMid($contents,$a,1))
        While $number > 0
            If $number >= 3^$power Then
            If $power < 0 Then ExitLoop
            $new = $new & Floor($number/3^$power)
            $number = $number - (3 ^ $power * Floor($number/3^$power))
        Else
            $new = $new & "0"
        EndIf
        If $number <= 3 ^ $power Then $power = $power - 1
        WEnd
        While mod(StringLen($new),5)
            $new = $new & "0"
        WEnd
    Next
    ControlSetText("blah","",$tb,$new)
EndFunc
Func decfunc()
$try = ""
While $try <> $pass
    $try = InputBox("Password Required","Please enter password to decrypt text","********","*")
WEnd
$msg = ""
$contents = GUICtrlRead($tb)
While StringLen($contents) > 0
    $number = StringLeft($contents,5)
    $tmp = 0
    for $y = 0 to 5
        $tmp = $tmp + Int(StringMid($number,stringlen($number)-$y,1))*3^$y
    Next
$msg = $msg & chr($tmp)
$contents = StringRight($contents,StringLen($contents)-5)
WEnd
ControlSetText("blah","",$tb,$msg)
EndFunc

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  

×