Jump to content

Encryption (One-Way)


Guest phreaker
 Share

Recommended Posts

Guest phreaker

I need to be able to do one-way in AutoIT.

I found no encryption samples in AutoIT so and after trying myself I don't know if it's possible. There's no type of advanced functions. I think I need at least xor() or something to be able to do a one-way? I don't even know if it's going to be possible to write my own xor() function in AutoIT...

Can someone help me out here?

Link to comment
Share on other sites

  • 2 weeks later...

I need to be able to do one-way in AutoIT.

I found no encryption samples in AutoIT so and after trying myself I don't know if it's possible.  There's no type of advanced functions.  I think I need at least xor() or something to be able to do a one-way?  I don't even know if it's going to be possible to write my own xor() function in AutoIT...

Can someone help me out here?

Hello.

You're probably best served by using one of the well-designed, well-scrutinized crypto packages available on the web.

Just for fun, here's a BitXor function. (BitOr and BitAnd are built in.) It was tested with AutoIt v3.0.77 and 0.84. BitNot depends on the language internals.

Func BitXor($x, $y)
  Return BitAnd( BitOr($x, $y), BitNot(BitAnd($x, $y)) )
EndFunc

Func BitNot($x)
  Return (0 - $x) - 1
EndFunc

In the simple demo below, if the character in the key is also in the text, the text will be corrupted---because BitXor($x, $x) = 0, and strings in AutoIt3 v0.84 cannot contain a Chr(0).

But I'm no expert.

; BitXor Demo

$text = "http://www.hiddensoft.com/forum/ | 555-0987"
$key = "Q"

If StringInStr($text, $key, 1) <> 0 Then
  MsgBox(0, "", "The text will be corrupted")
EndIf

$plaintext = $text
$text = Crypt($text, $key)
MsgBox(0, "Ciphertext", $text)
$text = Crypt($text, $key)
MsgBox(0, "Plaintext", $text)
Exit

Func Crypt($text, $key)
  $ctext = ""
  $k = Asc($key)
  For $i = 1 to StringLen($text)
    $char = StringMid($text, $i, 1)
    $t = Asc($char)
    $t = BitXor($t, $k)
    $char = Chr($t)
    $ctext = $ctext & $char
  Next
  Return $ctext
EndFunc

Func BitXor($x, $y)
  Return BitAnd( BitOr($x, $y), BitNot(BitAnd($x, $y)) )
EndFunc

Func BitNot($x)
  Return (0 - $x) - 1
EndFunc
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...