Jump to content
Sign in to follow this  
SoyArcano

Encrypting a string

Recommended Posts

SoyArcano

Hello i'm learning a little of cryptography only for educationals purporses. In my case i'm only trying to encrypt a easy string any string and then decrypt it and show it.

The code is:

ConsoleWrite(EnDeCrypt("What i am doing wrong","1234"))


;To ENcrypt and to DEcrypt your data.
Func EnDeCrypt($plaintxt, $psw)
    Local $a, $b, $i, $j, $k, $cipherby, $cipher
    Local $tempSwap, $temp, $intLength
    Local $sbox[256]
    Local $key[256]

    $intLength = StringLen($psw)
    For $a = 0 To 255
        $key[$a] = asc(Stringmid($psw, Mod($a ,$intLength)+1, 1))
        $sbox[$a] = $a
    Next

    $b = 0
    For $a = 0 To 255
        $b = Mod(($b + $sbox[$a] + $key[$a]),256)
        $tempSwap = $sbox[$a]
        $sbox[$a] = $sbox[$b]
        $sbox[$b] = $tempSwap
    Next

    For $a = 1 To StringLen($plaintxt)
        $i = Mod(($i + 1) ,256)
        $j = Mod(($j + $sbox[$i]) ,256)
        $k = $sbox[Mod(($sbox[$i] + $sbox[$j]) , 256)]

        $cipherby = BitXOR(Asc(StringMid($plaintxt, $a, 1)) , $k)
        $cipher = $cipher & Chr($cipherby)
    Next
    
    Return $cipher
EndFunc

Never write me the encrypted and decrypted string in console., only for string nothing bad.. thx!

Edited by SoyArcano

Share this post


Link to post
Share on other sites
SoyArcano

Oh thx i was searching that!

Share this post


Link to post
Share on other sites
Luigi

Exist an equivalent of this in PHP and Java?

 

Decrypt an encrypted message from AutoIt  in PHP or Java (Android Studio)?


Visit my repository

Share this post


Link to post
Share on other sites
Luigi

@Inververs thank you.

This is exactly what I asked, a script that encrypts in AutoIt and decrypts the message in PHP (or Java).

Very usefull.

Edited by Luigi

Visit my repository

Share this post


Link to post
Share on other sites
Luigi

ops, wrong post...

Edited by Luigi

Visit my repository

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  

×