Sign in to follow this  
Followers 0
SoyArcano

Encrypting a string

8 posts in this topic

#1 ·  Posted (edited)

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



#3 ·  Posted

Oh thx i was searching that!

Share this post


Link to post
Share on other sites

#4 ·  Posted

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

#5 ·  Posted

Share this post


Link to post
Share on other sites

#6 ·  Posted

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

@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

#8 ·  Posted (edited)

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  
Followers 0