Jump to content

equal encrypt function autoit and php


Cyber
 Share

Recommended Posts

why not? :D

$sString = "Now is the time for all good men to come to the aid of their country."

$sKey = "This is my key phrase."

$sCrypt = rc4($sKey, $sString)

$sString = rc4($sKey, $sCrypt)

STRING: BinaryToString($sString)

$bh = StringToBinary($sString)

$reString = rc4($sKey, $bh)

Why $reString <> $sString? :oops:

Try this:

$sData = "Now is the time for all good men to come to the aid of their country."
$sKey = "This is my key phrase."
$bCrypt = rc4($sKey, $sData)
$bDcrypt = rc4($sKey, $bCrypt)
$sDcrypt = BinaryToString($bDcrypt)
$bData = StringToBinary($sDcrypt)
$reCrypt = rc4($sKey, $bData)
$srecrypt = BinaryToString(rc4($sKey, $recrypt))
ConsoleWrite($sData&@CRLF&$sKey&@CRLF&$bCrypt&@CRLF&$bDcrypt&@CRLF&$sDcrypt&@CRLF&$bData&@CRLF&$reCrypt&@CRLF&$srecrypt)
Link to comment
Share on other sites

Quick question if i may

I have a feedback form i was going to use the smtp mailer by Jos for sending the form to a mail address is this code sufficient to keep the email password relativily safe?

$sString = "Now is the time for all good men to come to the aid of their country." ; plain string
$sKey = "This is my key phrase."
$sCrypt = rc4($sKey, $sString) ; encrypted binary
ConsoleWrite("Debug: $sCrypt = " & $sCrypt & @LF)
$sString = rc4($sKey, $sCrypt) ; decrypted binary
ConsoleWrite("Debug: $sString = " & $sString & @LF)
$sString = BinaryToString($sString) ; plain string
ConsoleWrite("Debug: $sString = " & $sString & @LF)
$bh = StringToBinary($sString) ; plain binary
ConsoleWrite("Debug: $bh = " & $bh & @LF)
$reString = rc4($sKey, $bh) ; encrypted binary
ConsoleWrite("Debug: $reString = " & $reString & @LF)
$reString = rc4($sKey, $reString) ; decrypted binary
ConsoleWrite("Debug: $reString = " & $reString & @LF)
$reString = BinaryToString($reString) ; plain string
ConsoleWrite("Debug: $reString = " & $reString & @LF)
 
; -------------------------------------------------------
; Function:  rc4
; Purpose:  An encryption/decryption RC4 implementation in AutoIt
; Syntax:  rc4($key, $value)
;   Where:  $key = encrypt/decrypt key
;      $value = value to be encrypted/decrypted
; On success returns encrypted/decrypted version of $value
; Author:  SkinnyWhiteGuy on the AutoIt forums at www.autoitscript.com/forum
; Notes:  The same function encrypts and decrypts $value.
; -------------------------------------------------------
Func rc4($key, $value)
    Local $S[256], $i, $j, $c, $t, $x, $y, $output
    Local $keyLength = BinaryLen($key), $valLength = BinaryLen($value)
    For $i = 0 To 255
        $S[$i] = $i
    Next
    For $i = 0 To 255
        $j = Mod($j + $S[$i] + Dec(StringTrimLeft(BinaryMid($key, Mod($i, $keyLength) + 1, 1), 2)), 256)
        $t = $S[$i]
        $S[$i] = $S[$j]
        $S[$j] = $t
    Next
    For $i = 1 To $valLength
        $x = Mod($x + 1, 256)
        $y = Mod($S[$x] + $y, 256)
        $t = $S[$x]
        $S[$x] = $S[$y]
        $S[$y] = $t
        $j = Mod($S[$x] + $S[$y], 256)
        $c = BitXOR(Dec(StringTrimLeft(BinaryMid($value, $i, 1), 2)), $S[$j])
        $output = Binary($output) & Binary('0x' & Hex($c, 2))
    Next
    Return $output
EndFunc   ;==>rc4
Edited by Chimaera
Link to comment
Share on other sites

Try this:

$sData = "Now is the time for all good men to come to the aid of their country."
$sKey = "This is my key phrase."
$bCrypt = rc4($sKey, $sData)
$bDcrypt = rc4($sKey, $bCrypt)
$sDcrypt = BinaryToString($bDcrypt)
$bData = StringToBinary($sDcrypt)
$reCrypt = rc4($sKey, $bData)
$srecrypt = BinaryToString(rc4($sKey, $recrypt))
ConsoleWrite($sData&@CRLF&$sKey&@CRLF&$bCrypt&@CRLF&$bDcrypt&@CRLF&$sDcrypt&@CRLF&$bData&@CRLF&$reCrypt&@CRLF&$srecrypt)

Yes, because I'm sure the OP is still having trouble with this 4 years later.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Just for reference: In latest Autoit is standard Crypt UDF which use system crypting

There is also RC4 algoritmus available ($CALG_RC4)

#Include <Crypt.au3>
_Crypt_EncryptData($vData, $vCryptKey, $iALG_ID[, $fFinal = True])
_Crypt_DecryptData($vData, $vCryptKey, $iALG_ID[, $fFinal = True])
Edited by Zedna
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...