Jump to content
ka0z

[Autoit] TEA Encryption

Recommended Posts

This code shows how to make TEA Encryption by legend90

Func _XXTEA_Encrypt ( $ Data , $ Key )
$ Data = Binary ( $ Data )
Local $ datalen = BinaryLen ( $ Data )
If $ datalen = 0 Then
Return ""
ElseIf $ datalen < 8 Then
$ Datalen = 8
EndIf

Local $ Opcode = ''
Local $ CodeBuffer = DllStructCreate ( "byte [" & BinaryLen ( $ Opcode ) & "]" )
DllStructSetData ( $ CodeBuffer , 1 , $ Opcode )

Local $ V = DllStructCreate ( "byte [" & Ceiling ( $ datalen / 4 ) * 4 & "]" )
DllStructSetData ( $ V , 1 , $ Data )

Local $ K = DllStructCreate ( "byte [16]" )
DllStructSetData ( $ K , 1 , $ Key )

DllCall ( "user32.dll" , "none" , "CallWindowProc" , "ptr" , DllStructGetPtr ( $ CodeBuffer ) , _
"Ptr" , DllStructGetPtr ( $ V ) , _
"Int" , Ceiling ( $ datalen / 4 ) , _
"Ptr" , DllStructGetPtr ( $ K ) , _
"Int" , 0 )

Local $ Ret = DllStructGetData ( $ V , 1 )
$ CodeBuffer = 0
$ V = 0
$ K = 0
Return $ Ret
EndFunc

Func _XXTEA_Decrypt ( $ Data , $ Key )
$ Data = Binary ( $ Data )
Local $ datalen = BinaryLen ( $ Data )
If $ datalen = 0 Then Return ""

Local $ Opcode = ''
Local $ CodeBuffer = DllStructCreate ( "byte [" & BinaryLen ( $ Opcode ) & "]" )
DllStructSetData ( $ CodeBuffer , 1 , $ Opcode )

Local $ V = DllStructCreate ( "byte [" & Ceiling ( $ datalen / 4 ) * 4 & "]" )
DllStructSetData ( $ V , 1 , $ Data )

Local $ K = DllStructCreate ( "byte [16]" )
DllStructSetData ( $ K , 1 , $ Key )

DllCall ( "user32.dll" , "none" , "CallWindowProc" , "ptr" , DllStructGetPtr ( $ CodeBuffer ) , _
"Ptr" , DllStructGetPtr ( $ V ) , _
"Int" , Ceiling ( $ datalen / 4 ) , _
"Ptr" , DllStructGetPtr ( $ K ) , _
"Int" , 0 )

Local $ Ret = DllStructGetData ( $ V , 1 )
$ CodeBuffer = 0
$ V = 0
$ K = 0
Return $ Ret
EndFunc

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...