argumentum

RC4 on win98, ws2003, win10

1 post in this topic

#1 ·  Posted (edited)

I wanted to use Ward's code but did'nt work on server2003, the old _StringEncrypt is not RC4, the one that comes now I can't use in win98, so here is a port. Could not find one in the forums. This should act just like Ward's, but a thousand times slower.

#include "RC4.au3"

Local $p = 'key'
Local $d = ', lots of data'
$d = $d & $d;&$d&$d&$d&$d&$d&$d&$d&$d&$d&$d&$d&$d&$d


Local $t = TimerInit()
$Encrypt = _RC4($d, $p)
ConsoleWrite("1 ward $Encrypt >" & $Encrypt & "<" & @CRLF)
$Decrypt = _RC4($Encrypt, $p)
ConsoleWrite("1 ward $Decrypt >" & BinaryToString($Decrypt) & "<" & @CRLF & " time: " & Round(TimerDiff($t), 5) & " mSec." & @CRLF & @CRLF)


$Encrypt = rc4(StringToBinary($p), StringToBinary($d))
ConsoleWrite("2 this $Encrypt >" & Binary($Encrypt) & "<" & @CRLF)
$Decrypt = rc4(StringToBinary($p), BinaryToString($Encrypt))
ConsoleWrite("2 this $Decrypt >" & BinaryToString($Decrypt) & "<" & @CRLF & " time: " & Round(TimerDiff($t), 5) & " mSec." & @CRLF & @CRLF)


Func rc4($key_str, $data_str)

    ; convert input strings to arrays
    Local $key_str_u = StringSplit(BinaryToString($key_str), "")
    Local $data_str_u = StringSplit(BinaryToString($data_str), "")
    Local $key[$key_str_u[0]]
    Local $data[$data_str_u[0]]
    Local $i
    For $i = 0 To $key_str_u[0] - 1
        $key[$i] = Asc($key_str_u[$i + 1])
    Next
    For $i = 0 To $data_str_u[0] - 1
        $data[$i] = Asc($data_str_u[$i + 1])
    Next

    ; prepare key
    Local $state[256]
    For $i = 0 To 255
        $state[$i] = $i
    Next
    Local $tmp, $x = 0, $y = 0
    For $i = 0 To 255
        $y = Mod($key[$x] + $state[$i] + $y, 256)
        $tmp = $state[$i]
        $state[$i] = $state[$y]
        $state[$y] = $tmp
        $x = Mod(($x + 1), $key_str_u[0])
    Next

    ; rc4
    $x = 0
    $y = 0
    For $i = 0 To $data_str_u[0] - 1
        $x = Mod(($x + 1), 256)
        $y = Mod(($state[$x] + $y), 256)
        $tmp = $state[$x];
        $state[$x] = $state[$y]
        $state[$y] = $tmp
        $data[$i] = BitXOR($data[$i], $state[Mod(($state[$x] + $state[$y]), 256)])
    Next

    ; convert output back to a string
    $data_str = ""
    For $i = 0 To $data_str_u[0] - 1
        $data_str &= Chr($data[$i])
    Next

    Return $data_str
EndFunc   ;==>rc4
 

hope it helps for those needing autoit v3.2.12.1

Edit 1: found working code at this post:  , next time I'll pay more attention  :sweating:

Edited by argumentum

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

  • Similar Content

    • FMS
      By FMS
      Hello,
      I think this is a simple question if you know the answer.
      At this function i try to  (encrypt -> decrypt -> change -> encrypt ->decrypt->check ) an array.
      This is a snippet from a larger script but the error is the same.
      I do this encrypt decrypt action so i can save some setting along the way in a file.
      But at the end (when i change the data and not when i dont change the data) is empty.
      does somebody see what i'm doing wrong here?
       
      Func test() Local $LC_timestamp = @MDAY & "." & @MON & "." & @YEAR & "_" & @HOUR & ":" & @MIN & ":" & @SEC Global $GL_USS_base_count = 4 Global $GL_USS_base[$GL_USS_base_count][2] = [["nickname", "FMS"], ["last_login", $LC_timestamp], ["login_count", "1" ], ["naam3", $LC_timestamp]] Global $encrypted_GL_USS_true[$GL_USS_base_count] Global $encrypted_GL_USS_content_true[$GL_USS_base_count] Global $GL_array_decrypted_USS_names[$GL_USS_base_count] Global $GL_array_decrypted_USS_settings[$GL_USS_base_count] MsgBox($MB_SYSTEMMODAL, "should be 1", $GL_USS_base[2][1]) ;make for $i = 0 to $GL_USS_base_count -1 $encrypted_GL_USS_true[$i] = _Crypt_EncryptData($GL_USS_base[$i][0], $GL_encr_key_settings, $CALG_AES_128) $encrypted_GL_USS_content_true[$i] = _Crypt_EncryptData($GL_USS_base[$i][1], $GL_encr_key_settings, $CALG_AES_128) Next ;get for $i = 0 to $GL_USS_base_count -1 $GL_array_decrypted_USS_names[$i] = binarytostring(_Crypt_DecryptData(binary($encrypted_GL_USS_true[$i]), $GL_encr_key_settings, $CALG_AES_128)) $GL_array_decrypted_USS_settings[$i] = binarytostring(_Crypt_DecryptData(binary($encrypted_GL_USS_content_true[$i]), $GL_encr_key_settings, $CALG_AES_128)) Next MsgBox($MB_SYSTEMMODAL, "should be 1", $GL_array_decrypted_USS_settings[2]) ;change $GL_array_decrypted_USS_settings[2] = $GL_array_decrypted_USS_settings[2] + "1" MsgBox($MB_SYSTEMMODAL, "should be 2", $GL_array_decrypted_USS_settings[2]) ;save for $i = 0 to $GL_USS_base_count -1 $encrypted_GL_USS_true[$i] = _Crypt_EncryptData($GL_array_decrypted_USS_names[$i], $GL_encr_key_settings, $CALG_AES_128) $encrypted_GL_USS_content_true[$i] = _Crypt_EncryptData($GL_array_decrypted_USS_settings[$i], $GL_encr_key_settings, $CALG_AES_128) Next ;get for $i = 0 to $GL_USS_base_count -1 $GL_array_decrypted_USS_names[$i] = binarytostring(_Crypt_DecryptData(binary($encrypted_GL_USS_true[$i]), $GL_encr_key_settings, $CALG_AES_128)) $GL_array_decrypted_USS_settings[$i] = binarytostring(_Crypt_DecryptData(binary($encrypted_GL_USS_content_true[$i]), $GL_encr_key_settings, $CALG_AES_128)) Next ;check MsgBox($MB_SYSTEMMODAL, "should be 2", $GL_array_decrypted_USS_settings[2]) ;why is this emty????? EndFunc thanks in advanced
    • 31290
      By 31290
      Hi everyone, 
      I'm building some script that will encrypt some user password and store it in an ini file.
      I'd like to recall the password in a putty session but I can't figure out how to decrypt it:

      So far, I have:
      Global $Images = "C:\SAC_IS\ATL_Laptop\Resources\Images\" Global $WorkingDir = "C:\SAC_IS\Switches_Toolbox\" Global $Settings = $WorkingDir & "\Settings.ini" DirCreate ($WorkingDir) _FirstRun() While 1 Sleep(10) WEnd Func _FirstRun() If FileExists ("C:\SAC_IS\Switches_Toolbox\Settings.ini") Then _LoginfoGUI() Else MsgBox (64, "PUTTY EXECUTABLE", "First, select PUTTY.EXE path") Global $PuttyPath = FileOpenDialog("Please indicate putty.exe path", @HomeDrive, "exe (*.exe)") _LoginfoGUI() If @Error Then Global $Error = MsgBox(21, "Error!", "Can't find PUTTY.EXE!"& @CRLF & "Click Retry or Cancel to Quit") If $Error = $IDRETRY Then _FirstRun() Else _Exit() EndIf Else FileInstall ("C:\Users\h74033\Desktop\Scirpts\Switches\Settings.ini", $WorkingDir & "\Settings.ini", 1) IniWrite ($Settings, "Putty", "Path", $PuttyPath) EndIf EndIf ; SwitchesToolboxGui() Endfunc Func _Exit() Exit EndFunc Func _LoginfoGUI() Global $LoginfoGUI = GUICreate("Switches Toolbox Configuration", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $LoginfoGUI) GUICtrlCreatePic ($Images & "\SAClogo.jpg", 30, 10, 240, 80) GUISetBkColor ($Color_White) GUICtrlCreateLabel("-- SWITCHES TOOLBOX --", 85, 100, 150, 25) GUICtrlSetFont (-1, 8.5, 700, 0) GUICtrlCreateLabel("Please provide required information:", 10, 130, 250, 25) GUICtrlCreateLabel("-Global ID:", 10, 170, 60, 30) GUICtrlSetFont (-1, 8.5, 700, 0) GUICtrlCreateLabel("-Password:", 10, 210, 70, 30) GUICtrlSetFont (-1, 8.5, 700, 0) Global $GIDInput = GUICtrlCreateInput("", 90, 168, 80, 20) Global $PassInput = GUICtrlCreateInput("", 90, 205, 150, 20, $ES_PASSWORD) GUICtrlCreateButton ("Submit", 100, 245, 100, 25) GUICtrlSetOnEvent(-1, "_Submit") GUISetState(@SW_SHOW) EndFunc Func _Submit() Global $GID = GuiCtrlRead($GIDInput) Global $EncryptedPwd = _Crypt_HashData (GuiCtrlRead($PassInput), $CALG_MD2) IniWrite ($Settings, "Username", "Gid", $Gid) IniWrite ($Settings, "Encryption", "Password", $EncryptedPwd) ;MsgBox(0, "re", $EncryptedPwd) EndFunc How can I achieve that please?
      Thanks in advance
       
    • MikahS
      By MikahS
      Short-Order Encrypter
      Just a fun project I had making a Crypt GUI that will encrypt and decrypt messages and files. All regular encryption types have been included for use. It will dynamically ask for a password, making it so there are never any passwords stored inside script. All dynamically built. I have included source code for your pleasure
       
       
       
      I wanted to get this onto the forum just see if anyone had any use for it. I am open and listening for questions, concerns, and comments
       
      Short-Order Encrypter.zip
      Short-Order EncrypterV1.0.5.zip
      Short-Order EncrypterV1.5.0.zip
      Short-Order Encrypter V1.6.0.zip
      Short-Order Encrypter V1.6.1.zip
       
      Current Version: 1.6.1.0
       
       
      Version History:



    • meows
      By meows
      69 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\Icons\TC128.ico #AutoIt3Wrapper_Outfile=Flyboy_Personal_Encryption_tool.exe #AutoIt3Wrapper_Outfile_x64=Flyboy_Personal_Encryption_toolx64.exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Comment=All purpose text crypt tool #AutoIt3Wrapper_Res_Description=Flyboy_Personal_Encryption_tool #AutoIt3Wrapper_Res_Fileversion=2.2.2. #AutoIt3Wrapper_Res_LegalCopyright=Reardon Studio #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <String.au3> #include <MsgBoxConstants.au3> _Main() ;;;;;;;;;;;;;;;;;;;;;;;;;;;; Flyboy_Personal_Encryption_tool Func _Main() Local $WinMain, $CopyButton, $EditText, $InputPass, $InputLevel, $EncryptButton, $DecryptButton, $string ; GUI and String stuff $WinMain = GUICreate('Jim Smiths (Flyboy) Personal Encryption tool', 800, 400) GUISetBkColor(0xA6CAF0) GUICtrlSetDefBkColor( 0x00ced1) ; Creates window $EditText = GUICtrlCreateEdit('', 5, 5, 760, 350) ; Creates main edit $InputPass = GUICtrlCreateInput('', 5, 360, 160, 20, 0x21) ; Creates the password box with blured/centered input $InputLevel = GUICtrlCreateInput(1, 180, 360, 50, 20, 0x2001) GUICtrlSetLimit(GUICtrlCreateUpdown($InputLevel), 10, 1) ; These two make the level input with the Up|Down ability $EncryptButton = GUICtrlCreateButton('Encrypt', 350, 360, 105, 35) ; Encryption button GUICtrlSetBkColor($EncryptButton, 0xff4500) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $DecryptButton = GUICtrlCreateButton('Decrypt', 460, 360, 105, 35) ; Decryption button GUICtrlSetBkColor($DecryptButton, 0xe0ffff) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $CopyButton = GUICtrlCreateButton('CopyButton', 570, 360, 105, 35) ; CopyButton GUICtrlSetBkColor($CopyButton, 0x00ffff) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $HelpButton = GUICtrlCreateButton('HelpButton', 690, 360, 105, 35) ; HelpButton GUICtrlSetBkColor($HelpButton, 0x00ffff) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlCreateLabel('Password', 15, 385) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ;;GUISetBkColor(-1,0xA6CAF0 GUICtrlCreateLabel('Level of encryption 1=low 10=high', 110, 382, 265, 35) ; Simple text labels so you know what is what GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState() ; Shows window While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $EncryptButton GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything $string = GUICtrlRead($EditText) ; Saves the editbox for later GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message GUICtrlSetData($EditText, _StringEncrypt(1, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ; The encryption starts with 1/0 to tell it to encrypt/decrypt ; The encryption then has the string that we saved for later from edit box ; It then reads the password box & Reads the level box GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on ;GUISetState(@SW_SHOW, $CopyButton) ; This turns the CopyButton back on Case $DecryptButton GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing $string = GUICtrlRead($EditText) ; Saves the editbox for later GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message GUICtrlSetData($EditText, _StringEncrypt(0, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel))) ; Calls the encryption. Sets the data of editbox with the encrypted string ; The encryption starts with 1/0 to tell it to encrypt/decrypt ; The encryption then has the string that we saved for later from edit box ; It then reads the password box & Reads the level box GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on popup Case $CopyButton GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything GUICtrlSetState($EditText, $GUI_FOCUS) $string = GUICtrlRead($EditText) ; Saves the editbox for later ClipPut($string) ; Add new data to the clipboard. ;Run("about.exe") ; Help about. Case $HelpButton MsgBox(262208, "Help Information", _ "Type your message in any application, Outlook, Thunderbird, Office, or" & @LF & _ "even in the Encryption program, although I did not add Spell Check," & @LF & @LF & _ "When message is ready paste it into the Encryption window, " & @LF & @LF & _ "Type in a password and a Encryption level if sending a message to" & @LF & _ "NASA I recommend Encryption level 10 but for normal use and your" & @LF & _ "positive NSA is not watching you. Use level One," & @LF & @LF & _ "Now click the Encrypt Button, When the message looks like Egyptian Hieroglyphics it is complete, " & @LF & @LF & _ "Click the Copy Button and past into your mail program and click send.;" & @LF & @LF & _ "When you receive a Encrypted message. I suggest you use EDIT SELECT ALL and EDIT COPY to Select the Encrypted message " & @LF & @LF & _ "and then paste it into the Encryption window. The reason is the Encrypted message is one LONG line of code " & @LF & _ " and will reach 50,000 characters before making a new line. Type in the password and Encryption level" & @LF & _ "Now you may click the Decryption button and read your safe and secure from all prying eyes personal message," & @LF & @LF & _ "NOTE:: If your computer is used by others, you can secure all manner of messages, notes, letters, memo's " & @LF & _ "and the like with this program." & @LF & @LF & _ "LAST A HINT.. CALL or send a post or a email, to the person(s) whom you share this program " & @LF & _ "and decide on a password and Encryption level you will use, and use the same settings for all messages," & @LF & _ " " & @LF & _ "If You Forget Either The Password Or Encryption Level That Message Is Lost Forever!" & @LF & _ "Christine", 0) EndSwitch WEnd ; Continue loop untill window is closed Exit EndFunc ;==>_Main I patched together a simple message encryption for a friend. all works perfect if both computers, the sender and receiver use the same operating system. but if you send a message from a win7/32 bit and the receiver is using win7/64bit the message is scrambled and unreadable.
      I have no clue as to why this is happening, and would love to understand it and fix it,
      Also. if used on a XP32 bit, the compiled 32bit errors out with this
        Server not found Firefox can't find the server at flyboy_personal_encryption_tool.   * Check the address for typing errors such as *ww*.example.com instead     of *www*.example.com   * If you are unable to load any pages, check your computer's network     connection.   * If your computer or network is protected by a firewall or proxy,     make sure that Firefox is permitted to access the Web. Try Again Report this errorâ–¼ <#> Reporting the address and certificate information for will help us identify and block malicious sites. Thanks for helping create a safer web! Automatically report errors in the future Learn more… <https://support.mozilla.org/kb/certificate-pinning-reports> Report Try again Sending report Report sent Yet the 64bit compiled version runs but when sending a message to win7/32 the message is unreadable.
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=..\Icons\TC128.ico #AutoIt3Wrapper_Outfile=Flyboy_Personal_Encryption_tool.exe #AutoIt3Wrapper_Outfile_x64=Flyboy_Personal_Encryption_toolx64.exe #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Comment=All purpose text crypt tool #AutoIt3Wrapper_Res_Description=Flyboy_Personal_Encryption_tool #AutoIt3Wrapper_Res_Fileversion=2.2.2. #AutoIt3Wrapper_Res_LegalCopyright=Reardon Studio #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <String.au3> #include <MsgBoxConstants.au3> _Main() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;     Flyboy_Personal_Encryption_tool Func _Main()     Local $WinMain, $CopyButton, $EditText, $InputPass, $InputLevel, $EncryptButton, $DecryptButton, $string     ; GUI and String stuff     $WinMain = GUICreate('Jim Smiths (Flyboy) Personal Encryption tool', 800, 400)     GUISetBkColor(0xA6CAF0)     GUICtrlSetDefBkColor( 0x00ced1)  ; Creates window     $EditText = GUICtrlCreateEdit('', 5, 5, 760, 350)    ; Creates main edit     $InputPass = GUICtrlCreateInput('', 5, 360, 160, 20, 0x21)  ; Creates the password box with blured/centered input     $InputLevel = GUICtrlCreateInput(1, 180, 360, 50, 20, 0x2001)     GUICtrlSetLimit(GUICtrlCreateUpdown($InputLevel), 10, 1)     ; These two make the level input with the Up|Down ability     $EncryptButton = GUICtrlCreateButton('Encrypt', 350, 360, 105, 35)    ; Encryption button     GUICtrlSetBkColor($EncryptButton, 0xff4500)     GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")     $DecryptButton = GUICtrlCreateButton('Decrypt', 460, 360, 105, 35)    ; Decryption button      GUICtrlSetBkColor($DecryptButton, 0xe0ffff)     GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")     $CopyButton = GUICtrlCreateButton('CopyButton', 570, 360, 105, 35)    ; CopyButton     GUICtrlSetBkColor($CopyButton, 0x00ffff)     GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $HelpButton = GUICtrlCreateButton('HelpButton', 690, 360, 105, 35)    ; HelpButton     GUICtrlSetBkColor($HelpButton, 0x00ffff)     GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlCreateLabel('Password', 15, 385)     GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")     GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)   ;;GUISetBkColor(-1,0xA6CAF0     GUICtrlCreateLabel('Level of encryption 1=low 10=high', 110, 382, 265, 35)    ; Simple text labels so you know what is what     GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)     GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState() ; Shows window While 1         Switch GUIGetMsg()             Case $GUI_EVENT_CLOSE                 ExitLoop             Case $EncryptButton                 GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything                 $string = GUICtrlRead($EditText) ; Saves the editbox for later                 GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message                 GUICtrlSetData($EditText, _StringEncrypt(1, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel)))                 ; Calls the encryption. Sets the data of editbox with the encrypted string                 ; The encryption starts with 1/0 to tell it to encrypt/decrypt                 ; The encryption then has the string that we saved for later from edit box                 ; It then reads the password box & Reads the level box                 GUISetState(@SW_ENABLE, $WinMain)   ; This turns the window back on                 ;GUISetState(@SW_SHOW, $CopyButton) ; This turns the CopyButton back on             Case $DecryptButton                 GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing                 $string = GUICtrlRead($EditText) ; Saves the editbox for later                 GUICtrlSetData($EditText, 'Please wait while the text is Encrypted/Decrypted.') ; Friendly message                 GUICtrlSetData($EditText, _StringEncrypt(0, $string, GUICtrlRead($InputPass), GUICtrlRead($InputLevel)))                 ; Calls the encryption. Sets the data of editbox with the encrypted string                 ; The encryption starts with 1/0 to tell it to encrypt/decrypt                 ; The encryption then has the string that we saved for later from edit box                 ; It then reads the password box & Reads the level box                 GUISetState(@SW_ENABLE, $WinMain) ; This turns the window back on  popup             Case $CopyButton     GUISetState(@SW_DISABLE, $WinMain) ; Stops you from changing anything     GUICtrlSetState($EditText, $GUI_FOCUS)                 $string = GUICtrlRead($EditText) ; Saves the editbox for later                      ClipPut($string)  ; Add new data to the clipboard.                 ;Run("about.exe")  ; Help about.             Case $HelpButton                 MsgBox(262208, "Help Information", _     "Type your message in any application, Outlook, Thunderbird, Office, or" & @LF & _     "even in the Encryption program, although I did not add Spell Check," & @LF & @LF & _     "When message is ready paste it into the Encryption window, " & @LF & @LF & _     "Type in a password and a Encryption level if sending a message to" & @LF & _     "NASA I recommend Encryption level 10 but for normal use and your" & @LF & _     "positive NSA is not watching you. Use level One," & @LF & @LF & _     "Now click the Encrypt Button, When the message looks like Egyptian Hieroglyphics it is complete, " & @LF & @LF & _     "Click the Copy Button and past into your mail program and click send.;" & @LF & @LF & _     "When you receive a Encrypted message. I suggest you use EDIT SELECT ALL and EDIT COPY to Select the Encrypted message  " & @LF & @LF & _     "and then paste it into the Encryption window. The reason is the Encrypted message is one LONG line of code " & @LF & _     " and will reach 50,000 characters before making a new line. Type in the password and Encryption level" & @LF & _     "Now you may click the Decryption button and read your safe and secure from all prying eyes personal message," & @LF & @LF & _     "NOTE:: If your computer is used by others, you can secure all manner of messages, notes, letters, memo's " & @LF & _     "and the like with this program." & @LF & @LF & _     "LAST A HINT.. CALL or send a post or a email, to the person(s) whom you share this program " & @LF & _     "and decide on a password and Encryption level you will use, and use the same settings for all messages," & @LF & _     " " & @LF & _     "If You Forget Either The Password Or Encryption Level That Message Is Lost Forever!" & @LF & _     "Christine", 0)         EndSwitch     WEnd ; Continue loop untill window is closed     Exit EndFunc   ;==>_Main Also thank you TheSaint for Dialog Maker, it makes a great help popup.
      So how do we make the encrypted string decrypt correctly on different operating systems and processors?
      The back story is Flyboy's oldest daughter just reconnected to her father, and wants to make
      peace, However daughter number 2 who lives with the oldest daughter is still filled with bad things. and the oldest daughter is worried if her sister finds messages from their Father to her the house will implode,
      I thought a easy answer was to encrypt messages,, boy was I wrong.
       
        Many thanks for reading,,
    • wraithdu
      By wraithdu
      This is my implementation of CipherSaber-2 ( http://ciphersaber.gurus.org/ ). CipherSaber is a version of RC4 that adds a 10 byte random IV to each piece of encoded data. CipherSaber-2 augments this with a configurable number of key setup rounds ( http://ciphersaber.gurus.org/faq.html#cs2 ).

      I decided to do the actual encryption / decryption in machine code so it is fast enough to be used on moderately sized files. The key setup is still done in AutoIt.

      I prefer this routine to AutoIt's _StringEncrypt because the output is the same size as the input, regardless of key rounds or encryption rounds.

      Note: If you visit the site to learn more or run the official test cases, a bunch of the links incorrectly point to a .com domain. Just change those to .org and they will work properly.


      #include-once #include <Memory.au3> OnAutoItExitRegister("__CS_Cleanup") Global $__g_CS_pCode = 0 ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CipherSaber ; Description ...: Encrypt / decrypt a chunk of binary data. ; Syntax ........: _CipherSaber( $bData, $sKey [, $iKeyRounds = 20 [, $doEncrypt = True ]] ) ; Parameters ....: $bData - Chunk of binary data. ; $sKey - User key, string <= 246 characters, will be truncated if too long. ; $iKeyRounds - [optional] Number of rounds during key setup. Default is 20. ; $doEncrypt - [optional] Whether to encrypt or decrypt. Default is True. ; Return values .: The encrypted / decrypted binary data. ; Author ........: Erik Pilsits ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://ciphersaber.gurus.org/ ; Example .......: No ; =============================================================================================================================== Func _CipherSaber($bData, $sKey, $iKeyRounds = 20, $doEncrypt = True) Local $IV = Default If Not $doEncrypt Then $IV = BinaryMid($bData, 1, 10) ; ; RC4 has max key length of 256 bytes ; user key has max length of 246 bytes to allow for 10 bytes of random IV Local $state = __CS_KeySetup(StringLeft($sKey, 246), $IV, $iKeyRounds) Local $sOut = Binary("") If $doEncrypt Then $sOut = $IV Else $bData = BinaryMid($bData, 11) EndIf ; Return $sOut & __CS_Cipher($bData, $state) EndFunc ;==>_CipherSaber ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CipherSaber_File ; Description ...: Encrypt / decrypt a file. ; Syntax ........: _CipherSaber_File( $fileIn, $fileOut, $sKey [, $iKeyRounds = 20 [, $doEncrypt = True ]] ) ; Parameters ....: $fileIn - Path to the input file. ; $fileOut - Path to the output file. ; $sKey - User key, string <= 246 characters, will be truncated if too long. ; $iKeyRounds - [optional] Number of rounds during key setup. Default is 20. ; $doEncrypt - [optional] Whether to encrypt or decrypt. Default is True. ; Return values .: Success - 1 ; Failure - 0 and sets @error ; | 1 - Error opening input file for readin ; | 2 - Error opening output file for writing ; Author ........: Erik Pilsits ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _CipherSaber_File($fileIn, $fileOut, $sKey, $iKeyRounds = 20, $doEncrypt = True) Local $hIn = FileOpen($fileIn, 16) If $hIn = -1 Then Return SetError(1, 0, 0) Local $hOut = FileOpen($fileOut, 2+8+16) If $hOut = -1 Then FileClose($hIn) Return SetError(2, 0, 0) EndIf ; Local $IV = Default If Not $doEncrypt Then $IV = FileRead($hIn, 10) ; Local $state = __CS_KeySetup(StringLeft($sKey, 246), $IV, $iKeyRounds) If $doEncrypt Then FileWrite($hOut, $IV) ; Local $bData While 1 $bData = FileRead($hIn, 1024^2*2) If @error Then ExitLoop FileWrite($hOut, __CS_Cipher($bData, $state)) WEnd ; FileClose($hIn) FileClose($hOut) ; Return 1 EndFunc ;==>_CipherSaber_File #region INTERNAL FUNCTIONS Func __CS_KeySetup($sKey, ByRef $IV, $iKeyRounds) Local $key = StringToBinary($sKey) Local $i, $j, $n ; If $IV = Default Then ; encrypt ; create 10 bytes random data for IV $IV = "" For $i = 1 To 10 $IV &= Hex(Random(0, 255, 1), 2) Next $IV = Binary("0x" & $IV) EndIf $key &= $IV ; ; key setup ; use struct for key+IV because they are faster than BinaryMid Local $state[256], $keylen = BinaryLen($key) Local $tKey = DllStructCreate("byte[" & $keylen & "]") DllStructSetData($tKey, 1, $key) ; For $i = 0 To 255 $state[$i] = $i Next ; $j = 0 For $k = 1 To $iKeyRounds For $i = 0 To 255 $j = Mod($j + $state[$i] + DllStructGetData($tKey, 1, Mod($i, $keylen) + 1), 256) $n = $state[$i] $state[$i] = $state[$j] $state[$j] = $n Next Next ; create state struct from array Local $tState = DllStructCreate("byte[256]") For $i = 0 To 255 DllStructSetData($tState, 1, $state[$i], $i+1) Next Return $tState EndFunc ;==>__CS_KeySetup Func __CS_Cipher(Const ByRef $bData, ByRef $tState) ; initialize machine code If Not $__g_CS_pCode Then Local $bCode If @AutoItX64 Then $bCode = Binary("0x5557565385D27E508D42FF4531C931ED488D7401018D55010FB6EA4863C54C01C00FB618440FB6D34501D14181E1FF0000004D63D94D01C3410FB613881041881B440210450FB6D2430FB6041030014883C1014839F175BD5B5E5F5DC3") Else $bCode = Binary("0x5557565383EC0C8B5424248B4C242885D27E598B44242031DB31ED891C2401C2895424088D55010FB6EA8D14290FB61A0FB6F3885C24078B1C2401F381E3FF00000089DF01CF891C240FB61F881A0FB65C2407881F0FB61201F20FB6F20FB61431301083C0013B44240875B883C40C5B5E5F5DC20C00") EndIf $__g_CS_pCode = _MemVirtualAlloc(0, BinaryLen($bCode), $MEM_COMMIT, $PAGE_EXECUTE_READWRITE) DllStructSetData(DllStructCreate("byte[" & BinaryLen($bCode) & "]", $__g_CS_pCode), 1, $bCode) EndIf ; set data to struct Local $i = 0, $j = 0, $n, $len = BinaryLen($bData) Local $tData = DllStructCreate("byte[" & $len & "]") DllStructSetData($tData, 1, $bData) ; call cipher DllCallAddress("none", $__g_CS_pCode, "struct*", $tData, "int", $len, "struct*", $tState) ; ;~ For $k = 1 To $len ;~ $i = Mod($i + 1, 256) ;~ $j = Mod($j + $state[$i], 256) ;~ $n = $state[$i] ;~ $state[$i] = $state[$j] ;~ $state[$j] = $n ;~ $n = Mod($state[$i] + $state[$j], 256) ;~ DllStructSetData($tData, 1, BitXOR($state[$n], Int(DllStructGetData($tData, 1, $k))), $k) ;~ Next ; Return DllStructGetData($tData, 1) EndFunc ;==>__CS_Cipher Func __CS_Cleanup() If $__g_CS_pCode Then _MemVirtualFree($__g_CS_pCode, 0, $MEM_RELEASE) EndFunc ;==>__CS_Cleanup #endregion INTERNAL FUNCTIONS
      cipher.c

      void __stdcall cipher(unsigned char src[], int srcSize, unsigned char state[256]) { int c = 0, i = 0, j = 0, n = 0; for (c = 0; c < srcSize; c++) { i = (i + 1) % 256; j = (j + state[i]) % 256; n = state[i]; state[i] = state[j]; state[j] = n; src[c] = state[((state[i] + state[j]) % 256)] ^ src[c]; } }
      Example

      #include <_CipherSaber.au3> ; NOTE: the IV is random data, so the encrypted data is different each time $p = "mypassword" ; string $s = "Some string to encrypt" $e = _CipherSaber(StringToBinary($s), $p) ConsoleWrite("encrypted: " & $e & @CRLF) ; $e is already binary data, default number of key rounds is 20, set flag to decrypt ; returned decrypted data is also binary $d = _CipherSaber($e, $p, 20, False) ConsoleWrite("decrypted: " & BinaryToString($d) & @CRLF) ConsoleWrite("---------------------" & @CRLF) ; file $f = @DesktopDir & "\in.txt" $o = @DesktopDir & "\enc.txt" $o2 = @DesktopDir & "\dec.txt" FileWrite($f, "Some sensitive file") ConsoleWrite("original file: " & Binary(FileRead($f)) & @CRLF) _CipherSaber_File($f, $o, $p) ConsoleWrite("encrypted file: " & Binary(FileRead($o)) & @CRLF) ; default key rounds 20, flag to decrypt _CipherSaber_File($o, $o2, $p, 20, False) ConsoleWrite("decrypted file: " & Binary(FileRead($o2)) & @CRLF) ; cleanup FileDelete($f) FileDelete($o) FileDelete($o2)