Encrypter

  • Moin Moin. Also ich hatte mir in der letzten Woche in den Kopf gesetzt einen eigenen Encrypter zu schreiben. Und hier ist mal das kleine Programm..

    Wer schon mal eine SMS geschrieben hat, kann es schon selbst entschlüsseln ;) , wenn nicht guckt man in den SourceCode :P

    Viel Spaß damit ^^

    Spoiler anzeigen
    [autoit]

    #include <Guiconstants.au3>
    #include <ProgressConstants.au3>
    #include <EditConstants.au3>
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Include <GuiEdit.au3>
    #include <StaticConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    fileinstall ( "background.jpg", @tempdir & "\emkayback.jpg" )

    [/autoit] [autoit][/autoit] [autoit]

    ;========GUI============;
    GUICreate ( "eNcrypt0r", 350, 450, -1,-1 )
    $pic =guictrlcreatepic ( @tempdir & "\emkayback.jpg", 0, 0, 350, 450 )
    GUICtrlSetState ( $pic, $Gui_disable )
    ;==========PIC=========;
    $reg = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\eNcrypt0r", "Path" )
    If $reg <> "" then
    GUICtrlSetImage ( $pic, $reg )
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;=======BUTTONS etc. ==========;
    GUISetFont ( 11, 400, 0, 'Arial' )
    $string2 = GUICtrlCreateEdit ( "", 10, 10, 330, 170 , $ES_AUTOVSCROLL + $WS_VSCROLL)
    $button1 = GUICtrlCreateButton ( "EnCrypt", 10, 187 )
    $out = GUICtrlCreateEdit ( "", 10, 230, 330, 180 , $ES_AUTOVSCROLL + $WS_VSCROLL)
    $button2 = GUICtrlCreateButton ( "DeCrypt", 280, 187 )
    ;==============MENU=============;
    $menu = GUICtrlCreateMenu ("File" )
    $clip1 = GUICtrlCreateMenuItem ( "Copy encrypted Text to ClipBoard", $menu, 1 )
    $clip2 = GUICtrlCreateMenuItem ( "Copy decrypted Text to ClipBoard", $menu, 2 )
    GUICtrlCreateMenuItem ( "", $menu, 3 )
    $exen = GUICtrlCreateMenuItem ( "Export encrypted Text as .txt", $menu, 4 )
    $exde = GUICtrlCreateMenuItem ( "Export decrypted Text as .txt", $menu, 5 )
    GUICtrlCreateMenuItem ( "", $menu, 6 )
    $exit_ = GUICtrlCreateMenuItem ( "Exit", $menu, 7 )

    [/autoit] [autoit][/autoit] [autoit]

    ;===========Menu ABOUT===========;
    $menu2 = guictrlcreatemenu ( "Help")
    $menu21 = GUICtrlCreateMenuItem ( "Help", $menu2, 1 )
    $menu22 = GUICtrlCreateMenuItem ( "", $menu2, 2 )
    $menu23 = GUICtrlCreateMenuItem ( "About", $menu2, 3 )
    $menu24 = GUICtrlCreateMenuItem ( "", $menu2, 4 )
    $menu20 = GUICtrlCreateMenu( "Set Background", $menu2, 5 )
    $menu25 = GUICtrlCreateMenuItem ( "Set new Background", $menu20, 1 )
    $menu26 = GUICtrlCreateMenuItem ( "", $menu20, 2 )
    $menu27 = GUICtrlCreateMenuItem ( "Set Default Background", $menu20, 3 )
    Guisetstate ( @SW_SHOW )

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    ;=======Pic Set=====;
    case $msg = $menu25
    $open = FileOpenDialog ( "Select Image", @MyDocumentsDir, "Images (*.jpg;*.bmp)" )
    if $open = "" Then
    msgbox ( 48, "Error", "Please select a Image" )
    Else
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\eNcrypt0r", "Path", "REG_SZ", $open)
    GUICtrlSetImage ( $pic, $open )
    EndIf
    case $msg = $menu27
    ;=======Set default Pic==========;
    if FileExists ( @tempdir & "\emkayback.jpg") Then
    RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\eNcrypt0r", "Path", "REG_SZ", @tempdir&"\emkayback.jpg")
    GUICtrlSetImage ( $pic, @tempdir&"\emkayback.jpg")
    Else
    msgbox (48, "Error", "The Image is missing."&@crlf& "Restarting the Program should fix the Problem.")
    EndIf
    case $msg = $button1
    ;=========ENCRYPT============;
    call ( "crypt" )
    case $msg = $button2
    ;==========DECRYPT========;
    call ( "decrypt")
    case $msg = $exen
    ;=======Export encrypted Text=========;
    $read = guictrlread ( $out )
    $path = FileSaveDialog ( "Save encrypted Text", @scriptdir, "Encrypted Text (*.txt)", 0 )
    if $path = "" Then
    msgbox ( 48, "Error", "Please select a Path!" )
    Else
    FileWrite ( $path & ".txt", $read )
    EndIf
    case $msg = $exde
    ;==========Export decrypted Text========;
    $read1 = guictrlread ( $string2 )
    $path1 = FileSaveDialog ( "Save decrypted Text", @scriptdir, "Decrypted Text (*.txt)", 0 )
    if $path1 = "" Then
    msgbox (48, "Error", "Please select a Path!" )
    Else
    FileWrite ( $path1 & ".txt", $read1 )
    EndIf
    case $msg = $clip1
    ;===========Encrypted Text to ClipBoard====;
    $reader = guictrlread ($out )
    if $reader <> "" Then
    ClipPut ( $reader )
    EndIf
    case $msg = $clip2
    ;==========Decrypted Text to ClipBoard=====;
    $readis = GUICtrlRead ( $string2 )
    if $readis <> "" Then
    ClipPut ( $readis )
    EndIf
    case $msg = $exit_
    ;========EXIT=======;
    Exit
    case $msg = $menu23
    ;============ABOUT=============;
    msgbox (0, "About", "eNcrypt0r v 1.0b" & @crlf & @crlf & "Author: eMkay" & @crlf & @crlf & "(c) eMkay" )
    case $msg = $menu21
    ;===========HELP========;
    $gay = GUICreate ( "Help", 300, 490, -1, -1, $WS_BORDER )
    $b = GUICtrlCreateButton ( "OK", 8, 420, 280, 30 )
    $edit = GUICtrlCreatelabel ( 'Encrypt:'& @crlf &'-----------'& @crlf & @crlf & 'First write your Text in the upper Edit Field.' & @crlf &'Then click on the "EnCrypt" Button for your Text to be encrypted.'& @crlf &'The encrypted Text will be shown in the lower Edit Field'& @crlf & @crlf & 'Decrypt:'& @crlf &'-----------'& @crlf & @crlf &'First write your Text in the lower Edit Field.' & @crlf &'Then click on the "DeCrypt" Button for your Text to be decrypted.'& @crlf &'The decrypted Text will be shown in the upper Edit Field', 10, 10, 280, 400 )
    GUICtrlSetState ($edit, @sw_disable )
    GUICtrlSetFont (-1, 12, 4, 0, "arial" )
    GUISetState()
    While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    if $msg = $b Then
    GUIDelete ( $gay )
    ExitLoop
    EndIf
    WEnd
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    func crypt()
    $string1 = GUICtrlRead ( $string2 )
    $string =StringLower ( $string1 )
    $i = 1
    $x = 1
    $length = stringlen ( $string )
    $code = ""
    while $i <= $length
    $left = StringLeft ( $string, $x )
    $right = StringRight ( $left, 1 )
    if $right = " " Then
    $code = $code & "00 "
    ElseIf $right = "1" Then
    $code = $code & "19 "
    ElseIf $right = "2" Then
    $code = $code & "29 "
    ElseIf $right = "3" Then
    $code = $code & "39 "
    ElseIf $right = "4" Then
    $code = $code & "49 "
    ElseIf $right = "5" Then
    $code = $code & "59 "
    ElseIf $right = "6" Then
    $code = $code & "69 "
    ElseIf $right = "7" Then
    $code = $code & "79 "
    ElseIf $right = "8" Then
    $code = $code & "89 "
    ElseIf $right = "9" Then
    $code = $code & "99 "
    ElseIf $right = "0" Then
    $code = $code & "09 "
    elseif $right = "ä" Then
    $code = $code & "21 32 "
    elseif $right = "ö" Then
    $code = $code & "63 32 "
    elseif $right = "ü" Then
    $code = $code & "82 32 "
    elseif $right = "a" Then
    $code = $code & "21 "
    ElseIf $right = "b" Then
    $code = $code & "22 "
    ElseIf $right = "c" Then
    $code = $code & "23 "
    ElseIf $right = "d" Then
    $code = $code & "31 "
    ElseIf $right = "e" Then
    $code = $code & "32 "
    ElseIf $right = "f" Then
    $code = $code & "33 "
    ElseIf $right = "g" Then
    $code = $code & "41 "
    ElseIf $right = "h" Then
    $code = $code & "42 "
    ElseIf $right = "i" Then
    $code = $code & "43 "
    ElseIf $right = "j" Then
    $code = $code & "51 "
    ElseIf $right = "k" Then
    $code = $code & "52 "
    ElseIf $right = "l" Then
    $code = $code & "53 "
    ElseIf $right = "m" Then
    $code = $code & "61 "
    ElseIf $right = "n" Then
    $code = $code & "62 "
    ElseIf $right = "o" Then
    $code = $code & "63 "
    ElseIf $right = "p" Then
    $code = $code & "71 "
    ElseIf $right = "q" Then
    $code = $code & "72 "
    ElseIf $right = "r" Then
    $code = $code & "73 "
    ElseIf $right = "s" Then
    $code = $code & "74 "
    ElseIf $right = "t" Then
    $code = $code & "81 "
    ElseIf $right = "u" Then
    $code = $code & "82 "
    ElseIf $right = "v" Then
    $code = $code & "83 "
    ElseIf $right = "w" Then
    $code = $code & "91 "
    ElseIf $right = "x" Then
    $code = $code & "92 "
    ElseIf $right = "y" Then
    $code = $code & "93 "
    ElseIf $right = "z" Then
    $code = $code & "94 "
    Elseif $right = "ß" Then
    $code = $code & "74 74 "
    EndIf
    $x = $x + 1
    $i = $i + 1
    WEnd
    guictrlsetdata ( $out, $code)
    EndFunc
    func decrypt()
    $string11 = GUICtrlRead ( $out )
    $leer = StringRight ( $string11, 1)
    if $leer <> " " Then
    $string11 = $string11 & " "
    EndIf
    $stringx =StringLower ( $string11 )
    $ii = 1
    $xx = 3
    $lengthxx = stringlen ( $stringx )
    $lengthx = $lengthxx / 3
    $code2 = ""
    while $ii <= $lengthx
    $leftx = StringLeft ( $stringx, $xx )
    $rightx = StringRight ( $leftx, 3 )
    if $rightx = "00 " Then
    $code2 = $code2 & " "
    ElseIf $rightx = "19 " Then
    $code2 = $code2 & "1"
    ElseIf $rightx = "29 " Then
    $code2 = $code2 & "2"
    ElseIf $rightx = "39 " Then
    $code2 = $code2 & "3"
    ElseIf $rightx = "49 " Then
    $code2 = $code2 & "4"
    ElseIf $rightx = "59 " Then
    $code2 = $code2 & "5"
    ElseIf $rightx = "69 " Then
    $code2 = $code2 & "6"
    ElseIf $rightx = "79 " Then
    $code2 = $code2 & "7"
    ElseIf $rightx = "89 " Then
    $code2 = $code2 & "8"
    ElseIf $rightx = "99 " Then
    $code2 = $code2 & "9"
    ElseIf $rightx = "09 " Then
    $code2 = $code2 & "0"
    elseif $rightx = "21 32 " Then
    $code2 = $code2 & "ä"
    elseif $rightx = "63 32 " Then
    $code2 = $code2 & "ö"
    elseif $rightx = "82 32 " Then
    $code2 = $code2 & "ü"
    elseif $rightx = "21 " Then
    $code2 = $code2 & "a"
    ElseIf $rightx = "22 " Then
    $code2 = $code2 & "b"
    ElseIf $rightx = "23 " Then
    $code2 = $code2 & "c"
    ElseIf $rightx = "31 " Then
    $code2 = $code2 & "d"
    ElseIf $rightx = "32 " Then
    $code2 = $code2 & "e"
    ElseIf $rightx = "33 " Then
    $code2 = $code2 & "f"
    ElseIf $rightx = "41 " Then
    $code2 = $code2 & "g"
    ElseIf $rightx = "42 " Then
    $code2 = $code2 & "h"
    ElseIf $rightx = "43 " Then
    $code2 = $code2 & "i"
    ElseIf $rightx = "51 " Then
    $code2 = $code2 & "j"
    ElseIf $rightx = "52 " Then
    $code2 = $code2 & "k"
    ElseIf $rightx = "53 " Then
    $code2 = $code2 & "l"
    ElseIf $rightx = "61 " Then
    $code2 = $code2 & "m"
    ElseIf $rightx = "62 " Then
    $code2 = $code2 & "n"
    ElseIf $rightx = "63 " Then
    $code2 = $code2 & "o"
    ElseIf $rightx = "71 " Then
    $code2 = $code2 & "p"
    ElseIf $rightx = "72 " Then
    $code2 = $code2 & "q"
    ElseIf $rightx = "73 " Then
    $code2 = $code2 & "r"
    ElseIf $rightx = "74 " Then
    $code2 = $code2 & "s"
    ElseIf $rightx = "81 " Then
    $code2 = $code2 & "t"
    ElseIf $rightx = "82 " Then
    $code2 = $code2 & "u"
    ElseIf $rightx = "83 " Then
    $code2 = $code2 & "v"
    ElseIf $rightx = "91 " Then
    $code2 = $code2 & "w"
    ElseIf $rightx = "92 " Then
    $code2 = $code2 & "x"
    ElseIf $rightx = "93 " Then
    $code2 = $code2 & "y"
    ElseIf $rightx = "94 " Then
    $code2 = $code2 & "z"
    ElseIf $rightx = "74 74 " Then
    $code2 = $code2 & "ss"
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $xx = $xx + 3
    $ii = $ii + 1
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    guictrlsetdata ( $string2, $code2)
    EndFunc
    FileDelete (@tempdir & "\emkayback.jpg" )

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Einmal editiert, zuletzt von eMkay (31. Juli 2009 um 10:20)

  • Du könntest es ser einfac um einiges sicherer machen:

    Guck dir mal _stringencrypt an. Damit kannst du dein Prog um einiges sicherer machen. Un man kann die Nachricht nur entschlüsseln wenn man das Passwort hat.

    Computers are like Airconditioning. They don´t work with open Windows.

  • Ne es ging mir hierbei nur um den Spaß an der Sache :P Und die verwirklichung einer Idee^^

  • Achso, na dann is es super geworden

    Edit: Is mir erst jetzt aufgefallen, aber was ist die xskin.au3???

    Computers are like Airconditioning. They don´t work with open Windows.

  • Iwie kommt da bei mir nix raus wenn ich das von eistee decrypten will
    Edit: Sry war nur zu dummd afür xD

    Computers are like Airconditioning. They don´t work with open Windows.