Jump to content
Sign in to follow this  
ArxBzFhblxphS

..

Recommended Posts

ArxBzFhblxphS
Posted Image Edited by Thanubis

Share this post


Link to post
Share on other sites
BugFix

Set and Get data with DllStructSetData() and DllStructGetData(), then it works fine:

$ret = _xor("test","Test")
Msgbox(0,"Test - encode", $ret)

$ret = _xor($ret,"Test", True)
Msgbox(0,"Test - decode", $ret)

Func _xor($vData,$vKey,$fReturnString = False)
    Local $nDataLen, $nKeyLen, $vBin, $vSz
    Local $iDataPtr, $iKeyPtr = 0
    If IsBinary($vData) Then
        $nDataLen = BinaryLen($vData)
    Else
        $nDataLen = StringLen($vData)
    EndIf
    If IsBinary($vKey) Then
        $nKeyLen = BinaryLen($vKey)
    Else
        $nKeyLen = StringLen($vKey)
    EndIf
    $vBin = DllStructCreate("ubyte key[" & $nKeyLen & "];ubyte data[" & $nDataLen & "];ubyte zterm")
;~     $vBin.key = $vKey
;~     $vBin.data = $vData
    DllStructSetData($vBin, 'key', $vKey)
    DllStructSetData($vBin, 'data', $vData)
    For $iDataPtr = 1 To $nDataLen
        $iKeyPtr += 1
        DllStructSetData($vBin,2,BitXOR(DllStructGetData($vBin,2,$iDataPtr),DllStructGetData($vBin,1,$iKeyPtr)),$iDataPtr)
        If $iKeyPtr = $nKeyLen Then $iKeyPtr = 0
    Next
    If $fReturnString Then
        $vSz = DllStructCreate("char data[" & $nDataLen+1 & "]",DllStructGetPtr($vBin,2))
;~         Return $vSz.data
        Return DllStructGetData($vSz, 'data')
    EndIf
;~     Return $vBin.data
    Return DllStructGetData($vBin, 'data')
EndFunc

Best Regards BugFix  

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.