Jump to content

abc encryption


erifash
 Share

Recommended Posts

I basically coded the whole thing except for the scramble functions made by datkewlguy. He also gave me the idea for this and helped me out a lot.

This is a program that encrypts data by using what i call "halfway backwards encryption". It scrambles the word, character shifts it, the scrambles it again. All while doing it backwards because decrypt is encrypt and encrypt is decrypt. To get the maximum level of encryption-ness (not sure if that is a word :D ) you decrypt it while it is decrypted.

Well, here is our awesome :) work:

#NoTrayIcon
#include <GUIConstants.au3>

$w = 300
$h = 200
$l = ( @DesktopWidth - $w ) / 2
$t = ( @DesktopHeight - $h ) / 2
$win = "abc encryption"

$gui = GUICreate($win, $w, $h, $l, $t, $WS_MINIMIZEBOX + $WS_SYSMENU)
$edit = GUICtrlCreateEdit("", 0, 0, $w - 5, $h - 51, $ES_WANTRETURN + $ES_MULTILINE + $WS_TABSTOP + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL + $WS_VSCROLL + $WS_HSCROLL)
$encrypt = GUICtrlCreateButton("E n c r y p t", 0, $h - 51, ($w / 3) - 2, 20)
$decrypt = GUICtrlCreateButton("D e c r y p t", ($w / 3) - 2, $h - 51, ($w / 3) - 2, 20)
$clipboard = GUICtrlCreateButton("C o p y", ($w / 3 * 2) - 4, $h - 51, ($w / 3) - 2, 20)

GUISetState()

GUISetBkColor("0xFFFFFF", $gui)

GUICtrlSetState($edit, $GUI_FOCUS)

WinSetOnTop($win, "", 1)

While 1
  $msg = GUIGetMsg()
  Select
    Case $msg = $GUI_EVENT_CLOSE
      Exit
    Case $msg = $decrypt
      $sz_enc = GUICtrlRead($edit)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, "Encrypting...")
      $sz_enc = _Scramble($sz_enc)
      $sz_tmptxt = ""
      For $i = 1 to StringLen($sz_enc)
        $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_enc, $i, 1))
      Next
      $sz_tmptxt = _Scramble($sz_tmptxt)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, $sz_tmptxt)
    Case $msg = $encrypt
      $sz_dec = GUICtrlRead($edit)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, "Decrypting...")
      $sz_dec = _Unscramble($sz_dec)
      $sz_tmptxt = ""
      For $i = 1 to StringLen($sz_dec)
        $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_dec, $i, 1))
      Next
      $sz_tmptxt = _Unscramble($sz_tmptxt)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, $sz_tmptxt)
    Case $msg = $clipboard
      ClipPut(GUICtrlRead($edit))
  EndSelect
  Sleep(1)
Wend

Func abcdef($sz_t)
  If StringIsUpper($sz_t) Then
    If $sz_t = "A" Then Return "C"
    If $sz_t = "C" Then Return "A"
    If $sz_t = "B" Then Return "D"
    If $sz_t = "D" Then Return "B"
    If $sz_t = "E" Then Return "G"
    If $sz_t = "G" Then Return "E"
    If $sz_t = "F" Then Return "H"
    If $sz_t = "H" Then Return "F"
    If $sz_t = "I" Then Return "K"
    If $sz_t = "K" Then Return "I"
    If $sz_t = "J" Then Return "L"
    If $sz_t = "L" Then Return "J"
    If $sz_t = "M" Then Return "O"
    If $sz_t = "O" Then Return "M"
    If $sz_t = "N" Then Return "P"
    If $sz_t = "P" Then Return "N"
    If $sz_t = "Q" Then Return "S"
    If $sz_t = "S" Then Return "Q"
    If $sz_t = "R" Then Return "T"
    If $sz_t = "T" Then Return "R"
    If $sz_t = "U" Then Return "W"
    If $sz_t = "W" Then Return "U"
    If $sz_t = "V" Then Return "X"
    If $sz_t = "X" Then Return "V"
    If $sz_t = "Y" Then Return "Z"
    If $sz_t = "Z" Then Return "Y"
  EndIf
  If $sz_t = "a" Then Return "c"
  If $sz_t = "c" Then Return "a"
  If $sz_t = "b" Then Return "d"
  If $sz_t = "d" Then Return "b"
  If $sz_t = "e" Then Return "g"
  If $sz_t = "g" Then Return "e"
  If $sz_t = "f" Then Return "h"
  If $sz_t = "h" Then Return "f"
  If $sz_t = "i" Then Return "k"
  If $sz_t = "k" Then Return "i"
  If $sz_t = "j" Then Return "l"
  If $sz_t = "l" Then Return "j"
  If $sz_t = "m" Then Return "o"
  If $sz_t = "o" Then Return "m"
  If $sz_t = "n" Then Return "p"
  If $sz_t = "p" Then Return "n"
  If $sz_t = "q" Then Return "s"
  If $sz_t = "s" Then Return "q"
  If $sz_t = "r" Then Return "t"
  If $sz_t = "t" Then Return "r"
  If $sz_t = "u" Then Return "w"
  If $sz_t = "w" Then Return "u"
  If $sz_t = "v" Then Return "x"
  If $sz_t = "x" Then Return "v"
  If $sz_t = "y" Then Return "z"
  If $sz_t = "z" Then Return "y"
      
  If $sz_t = "0" Then Return "2"
  If $sz_t = "2" Then Return "0"
  If $sz_t = "1" Then Return "3"
  If $sz_t = "3" Then Return "1"
  If $sz_t = "4" Then Return "6"
  If $sz_t = "6" Then Return "4"
  If $sz_t = "5" Then Return "7"
  If $sz_t = "7" Then Return "5"
  If $sz_t = "8" Then Return "9"
  If $sz_t = "9" Then Return "8"
      
  If $sz_t = ")" Then Return "@"
  If $sz_t = "@" Then Return ")"
  If $sz_t = "!" Then Return "#"
  If $sz_t = "#" Then Return "!"
  If $sz_t = "$" Then Return "^"
  If $sz_t = "^" Then Return "$"
  If $sz_t = "%" Then Return "&"
  If $sz_t = "&" Then Return "%"
  If $sz_t = "*" Then Return "("
  If $sz_t = "(" Then Return "*"
      
  If $sz_t = "?" Then Return "+"  
  If $sz_t = "+" Then Return "?"
      
  If $sz_t = " " Then Return ":"  
  If $sz_t = ":" Then Return " "
      
  If $sz_t = @CR Then Return ""
  If $sz_t = @LF Then Return "¤"
  If $sz_t = "" Then Return @CR
  If $sz_t = "¤" Then Return @LF

  Return $sz_t
EndFunc

Func _Scramble($sText)
;; Scramble a text string.
   $iLen = StringLen($sText)
   $Scrambled = ""
   For $i1 = 1 To Int($iLen / 2)
      $Scrambled = $Scrambled & StringMid($sText, $iLen - $i1 + 1, 1) & StringMid($sText, $i1, 1)
   Next; $i1
; Pick up the odd character.
   If Mod($iLen, 2) Then
      $Scrambled = $Scrambled & StringMid($sText, $i1, 1)
   EndIf
   Return $Scrambled
EndFunc;==>_Scramble


Func _Unscramble($sText)
 ;; De-Scramble a Scrambled text that was scrambled by _Scramble.
   Local $iLen = StringLen($sText)
   Local  $i, $Unscrambled1, $Unscrambled2
   $Unscrambled1 = ""
   $Unscrambled2 = ""
   For $i1 = 1 To $iLen step 2
      $Unscrambled1 = StringMid($sText, $i1, 1) & $Unscrambled1
      $Unscrambled2 = $Unscrambled2 & StringMid($sText, $i1 + 1, 1)
   Next; $i1
 ; Pick up the odd character.
   If Mod($iLen, 2) Then
      $Unscrambled1 = StringMid($sText, $i1, 1) & $Unscrambled1
   EndIf
   $sText = $Unscrambled2 & $Unscrambled1
   Return $Unscrambled2 & $Unscrambled1
EndFunc ;==>_Unscramble

...all in such a tiny GUI...

Edited by erifash
Link to comment
Share on other sites

These are the results I got from encrypting the word 'test' and then encrypting the result of that.

test > rrqg > etst > rgqr > ttse > grqr > and back to test.

Thought you might find it interesting.

Edit: Very good though, I typed in about 2 sentences and I had no idea what came out lol. Decrypt this :).

¤:r.gzRPhn@bmgk#kz :wjad:t:r:jgmgaqfb::Logk
Edited by Burrup

qq

Link to comment
Share on other sites

you said:

"Nice Job!

Tell me if you decrypted this :)."

max security is the result of one press of the encrypt button, the longer the text, the longer it will take to decrypt.

Also, isnt it neat that it compresses multiple lines into one? and it still recognizes the line breaks and reassembles your casing/line breaks the same?

Link to comment
Share on other sites

max security is the result of one press of the encrypt button

<{POST_SNAPBACK}>

So each time I encrypt the encryption of another encryption, etc, of a word. It gets more un-secure each time? I thought the most safest encryption would be the middle one. Example with the word test again.

test > rrqg > etst > rgqr > ttse > grqr >  and back to test.

Wouldn't etst or rgqr be the safest?

Also, isnt it neat that it compresses multiple lines into one? and it still recognizes the line breaks and reassembles your casing/line breaks the same?

<{POST_SNAPBACK}>

Yes I noticed that :), add's even more to the encryption and decreases the chance of having someone crack it. Edited by Burrup

qq

Link to comment
Share on other sites

Yup, oh i have also changed the code so you do not have to hit the buttons (hotkeys are ^e and ^d)

#NoTrayIcon
#include <GUIConstants.au3>

HotKeySet( "^e", "encrypt2")
HotKeySet( "^d", "decrypt2")

$w = 300
$h = 200
$l = ( @DesktopWidth - $w ) / 2
$t = ( @DesktopHeight - $h ) / 2
$win = "ENCRYPTION - 2.0"

$gui = GUICreate($win, $w, $h, $l, $t, $WS_MINIMIZEBOX + $WS_SYSMENU)
$edit = GUICtrlCreateEdit("", 0, 0, $w - 5, $h - 51, $ES_WANTRETURN + $ES_MULTILINE + $WS_TABSTOP + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL + $WS_VSCROLL + $WS_HSCROLL)
$encrypt = GUICtrlCreateButton("E n c r y p t", 0, $h - 51, ($w / 3) - 2, 20)
$decrypt = GUICtrlCreateButton("D e c r y p t", ($w / 3) - 2, $h - 51, ($w / 3) - 2, 20)
$clipboard = GUICtrlCreateButton("C o p y", ($w / 3 * 2) - 4, $h - 51, ($w / 3) - 2, 20)

GUISetState(@SW_HIDE)

$trans = 0

WinSetTrans( $win, "", $trans)

GuiSetState(@SW_SHOW)

Do
$trans = $trans + 1
WinSetTrans( $win, "", $trans)
    Until $trans >= 255

GUISetBkColor("0xFFFFFF", $gui)

GUICtrlSetState($edit, $GUI_FOCUS)

WinSetOnTop($win, "", 1)

While 1
  $msg = GUIGetMsg()
  Select
    Case $msg = $GUI_EVENT_CLOSE
     myexit()
    Case $msg = $decrypt
      decrypt2()
    Case $msg = $encrypt
      encrypt2()
    Case $msg = $clipboard
      ClipPut(GUICtrlRead($edit))
  EndSelect
  Sleep(1)
Wend

Func abcdef($sz_t)
  If StringIsUpper($sz_t) Then
    If $sz_t = "A" Then Return "C"
    If $sz_t = "C" Then Return "A"
    If $sz_t = "B" Then Return "D"
    If $sz_t = "D" Then Return "B"
    If $sz_t = "E" Then Return "G"
    If $sz_t = "G" Then Return "E"
    If $sz_t = "F" Then Return "H"
    If $sz_t = "H" Then Return "F"
    If $sz_t = "I" Then Return "K"
    If $sz_t = "K" Then Return "I"
    If $sz_t = "J" Then Return "L"
    If $sz_t = "L" Then Return "J"
    If $sz_t = "M" Then Return "O"
    If $sz_t = "O" Then Return "M"
    If $sz_t = "N" Then Return "P"
    If $sz_t = "P" Then Return "N"
    If $sz_t = "Q" Then Return "S"
    If $sz_t = "S" Then Return "Q"
    If $sz_t = "R" Then Return "T"
    If $sz_t = "T" Then Return "R"
    If $sz_t = "U" Then Return "W"
    If $sz_t = "W" Then Return "U"
    If $sz_t = "V" Then Return "X"
    If $sz_t = "X" Then Return "V"
    If $sz_t = "Y" Then Return "Z"
    If $sz_t = "Z" Then Return "Y"
  EndIf
  If $sz_t = "a" Then Return "c"
  If $sz_t = "c" Then Return "a"
  If $sz_t = "b" Then Return "d"
  If $sz_t = "d" Then Return "b"
  If $sz_t = "e" Then Return "g"
  If $sz_t = "g" Then Return "e"
  If $sz_t = "f" Then Return "h"
  If $sz_t = "h" Then Return "f"
  If $sz_t = "i" Then Return "k"
  If $sz_t = "k" Then Return "i"
  If $sz_t = "j" Then Return "l"
  If $sz_t = "l" Then Return "j"
  If $sz_t = "m" Then Return "o"
  If $sz_t = "o" Then Return "m"
  If $sz_t = "n" Then Return "p"
  If $sz_t = "p" Then Return "n"
  If $sz_t = "q" Then Return "s"
  If $sz_t = "s" Then Return "q"
  If $sz_t = "r" Then Return "t"
  If $sz_t = "t" Then Return "r"
  If $sz_t = "u" Then Return "w"
  If $sz_t = "w" Then Return "u"
  If $sz_t = "v" Then Return "x"
  If $sz_t = "x" Then Return "v"
  If $sz_t = "y" Then Return "z"
  If $sz_t = "z" Then Return "y"
      
  If $sz_t = "0" Then Return "2"
  If $sz_t = "2" Then Return "0"
  If $sz_t = "1" Then Return "3"
  If $sz_t = "3" Then Return "1"
  If $sz_t = "4" Then Return "6"
  If $sz_t = "6" Then Return "4"
  If $sz_t = "5" Then Return "7"
  If $sz_t = "7" Then Return "5"
  If $sz_t = "8" Then Return "9"
  If $sz_t = "9" Then Return "8"
      
  If $sz_t = ")" Then Return "@"
  If $sz_t = "@" Then Return ")"
  If $sz_t = "!" Then Return "#"
  If $sz_t = "#" Then Return "!"
  If $sz_t = "$" Then Return "^"
  If $sz_t = "^" Then Return "$"
  If $sz_t = "%" Then Return "&"
  If $sz_t = "&" Then Return "%"
  If $sz_t = "*" Then Return "("
  If $sz_t = "(" Then Return "*"
      
  If $sz_t = "?" Then Return "+"  
  If $sz_t = "+" Then Return "?"
      
  If $sz_t = " " Then Return ":"  
  If $sz_t = ":" Then Return " "
      
  If $sz_t = @CR Then Return ""
  If $sz_t = @LF Then Return "¤"
  If $sz_t = "" Then Return @CR
  If $sz_t = "¤" Then Return @LF

  Return $sz_t
EndFunc

Func _Scramble($sText)
;; Scramble a text string.
   $iLen = StringLen($sText)
   $Scrambled = ""
   For $i1 = 1 To Int($iLen / 2)
      $Scrambled = $Scrambled & StringMid($sText, $iLen - $i1 + 1, 1) & StringMid($sText, $i1, 1)
   Next; $i1
; Pick up the odd character.
   If Mod($iLen, 2) Then
      $Scrambled = $Scrambled & StringMid($sText, $i1, 1)
   EndIf
   Return $Scrambled
EndFunc;==>_Scramble


Func _Unscramble($sText)
;; De-Scramble a Scrambled text that was scrambled by _Scramble.
   Local $iLen = StringLen($sText)
   Local  $i, $Unscrambled1, $Unscrambled2
   $Unscrambled1 = ""
   $Unscrambled2 = ""
   For $i1 = 1 To $iLen step 2
      $Unscrambled1 = StringMid($sText, $i1, 1) & $Unscrambled1
      $Unscrambled2 = $Unscrambled2 & StringMid($sText, $i1 + 1, 1)
   Next; $i1
; Pick up the odd character.
   If Mod($iLen, 2) Then
      $Unscrambled1 = StringMid($sText, $i1, 1) & $Unscrambled1
   EndIf
   $sText = $Unscrambled2 & $Unscrambled1
   Return $Unscrambled2 & $Unscrambled1
EndFunc;==>_Unscramble

func myexit()

Do
$trans = $trans - 1
WinSetTrans( $win, "", $trans)
    Until $trans <= 0
    exit
endfunc

func encrypt2()
      $sz_dec = GUICtrlRead($edit)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, "Encrypting...")
      $sz_dec = _Unscramble($sz_dec)
      $sz_tmptxt = ""
      For $i = 1 to StringLen($sz_dec)
        $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_dec, $i, 1))
      Next
      $sz_tmptxt = _Unscramble($sz_tmptxt)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, $sz_tmptxt)
      
      ClipPut(GUICtrlRead($edit))
  EndFunc
  
  func decrypt2()
      $sz_enc = GUICtrlRead($edit)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, "Decrypting...")
      $sz_enc = _Scramble($sz_enc)
      $sz_tmptxt = ""
      For $i = 1 to StringLen($sz_enc)
        $sz_tmptxt = $sz_tmptxt & abcdef(StringMid($sz_enc, $i, 1))
      Next
      $sz_tmptxt = _Scramble($sz_tmptxt)
      GUICtrlSetData($edit, "")
      GUICtrlSetData($edit, $sz_tmptxt)
            ClipPut(GUICtrlRead($edit))
      endfunc
Edited by datkewlguy
Link to comment
Share on other sites

The code you use is really inefficient, sorry to be rude :)

You could just 'shift' the characters using their ASCII code:

$sString = "Encrypting me softly"
; Breaking up string
$arString = StringSplit ( $sString, "" )

; Loading buffers
Local $sTemp = "", $iASCII = 0, $i = 0

; Looping through each character
For $i = 1 to $arString[0]
; Adding 5 to the characters ASCII value
    $iASCII = ASC ( $arString[$i] ) + 5
    
; Adding to buffer
    $sTemp = Chr( $iASCII ) & $sTemp
Next

; Copying buffer
$sString = $sTemp

; Displaying encrypted string
MsgBox("","Encrypted", $sString)

; Clearing buffers
Local $sTemp = "", $iASCII = 0, $i = 0

; Breaking up encrypted string
$arString = StringSplit ( $sString, "" )

; Looping through each character
For $i = 1 to $arString[0]
; Subtracting 5 from the characters ASCII value
    $iASCII = ASC ( $arString[$i] ) - 5
    
; Adding to buffer
    $sTemp = Chr( $iASCII ) & $sTemp
Next

; Displaying decrypted string
MsgBox("","Decrypted", $sTemp)
"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

each letter shifts up 3 or back 3, depending on where it falls in the alphabet (even or odd) the program reads how many chrs u have and goes to the middle (most secure) point in the alphabet, which is the hardest to decode. The letters don't all follow a certain rule (such as yours does with +1, +2, or something for all the letters) also, ours can compress multiple lines into one, and still keep the formatting, spacing, and casing in perfect tact. The order is changed as well. The order and shifting of characters kind of use a system of checks and balances to achieve the best encryption. I would have to say i do not believe that our method is ineffecient...

Link to comment
Share on other sites

How is the middle the most secure point in the alphabet? Your letters do follow a certain rule. Do you realize how hard it is to change each of the 50 If's you have if you wanted to improve your script?

You could modify my method to do everything yours does in a few minutes...

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

I think you misunderstood me. Not the middle of the alphabet, but it encrypts half the number of times as the number of letters in your string... test is encrypted twice... see, if you encrypt once, it decrypts once, if u decrypt once, encrypting makes it normal. Like your idea, u can shift forwards and backwards into its origional state by doing the opposite function. However, by using backwards halfway encryption, you can move to the middle, making it equally hard to encrypt/decrypt back into its origional state.

Link to comment
Share on other sites

How can you not do that using the method I've posted?

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

I can change the script... I'll use the same method as I use in PHP:

$Timer = TimerInit()
$sString = "Encrypting me softlyÿ"
$arString = StringSplit ( $sString, "" )

;===============================================================================
; Encrypting                                                                
;===============================================================================
Local $sTemp = "", $iASCII = 0, $i = 0

For $i = 1 to $arString[0]
    $iPadding = 9
    
    If Mod($i, 2) = 1 Then $iPadding = 3
    
    $iASCII = ASC ( $arString[$i] ) + $iPadding
    
    $sTemp = Chr( $iASCII ) & $sTemp
Next

$sString = $sTemp

MsgBox("","Encrypted", $sString & @LF & StringLen ( $sString ) & " characters in " & Round(TimerDiff ( $Timer )) & " ms")

;===============================================================================
; Decrypting                                                            
;===============================================================================
Local $sTemp = "", $iASCII = 0, $i = 0, $Timer = 0

$Timer = TimerInit()

$arString = StringSplit ( $sString, "" )

For $i = $arString[0] to 1 Step -1
    $iPadding = 9
    
    If Mod($i, 2) = 1 Then $iPadding = 3
        
    $iASCII = ASC ( $arString[$i] ) - $iPadding
    
    $sTemp = $sTemp & Chr( $iASCII )
Next

MsgBox("","Decrypted", $sTemp & @LF & StringLen ( $sString ) & " characters in " & Round(TimerDiff ( $Timer )) & " ms")

Much faster than your method (because of all the If's) but seems to be broken when it comes to a few characters.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
Link to comment
Share on other sites

Well... it shifts every other character differently, then spits it back backwards. There are _many_ other things I could add. It's easy to add via this method, and it's many, many times faster.

"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.
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...