Jump to content

Recommended Posts


High-quality encryption and without an increase in the size of the encrypted data, meaning the data before and
after encryption are exactly the same size as encryption above all attempts at frivolous decryption ... Thank you.

 

;High-quality encryption and without an increase in the size of the encrypted data, meaning the data before and
;after encryption are exactly the same size as encryption above all attempts at frivolous decryption ... Thank you.

; ASCII Code from 0 to 255 add 1 for 0 = 256 /// $yByteA = DllStructGetData($DataStructA,1,1) + 1

For $aByte = 1 To 256
For $bByte = 1 To 256
$ByArray = GBySet($aByte,$bByte)
$yByteA = $ByArray[0]
$yByteB = $ByArray[1]
$ByArray = GByGet($yByteA,$yByteB)
$yByteC = $ByArray[0]
$yByteD = $ByArray[1]
if $yByteC <> $aByte Or $yByteD <> $bByte Then MsgBox(0,"","TestA error")
Next
Next

MsgBox(0,"","TestA Ok")

For $aByte = 1 To 256
$yByteA = yBySet($aByte)
$yByteB = yByGet($yByteA)
if $yByteB <> $aByte Then MsgBox(0,"","TestB error")
Next

MsgBox(0,"","TestB Ok")

$DataSt = DllStructCreate("char[15]")
DllStructSetData($DataSt,1,"Autoit Wolf9228")

DataEncrypt("oman",$DataSt)

MsgBox(0,"Encrypt",DllStructGetData($DataSt,1))

DataDecrypt("oman",$DataSt)

MsgBox(0,"Decrypt",DllStructGetData($DataSt,1))


Func DataDecrypt($Password,$DataStructB)

if IsDllStruct($DataStructB) = 0 Or StringLen($Password) = 0 Then Return False

$ySize = DllStructGetSize($DataStructB)

$DataStructA = DllStructCreate("Byte[" &  $ySize & "]",DllStructGetPtr($DataStructB))

$nPassword = StringSplit($Password,"")
$2Bytes  =  DllStructCreate("Byte[2]")

Local $NumE = $nPassword[0] * 2 , $NumF = 1 , $SPassword[$NumE + 1]

For $NumA = 1 To $nPassword[0]
DllStructSetData($2Bytes,1,AscW($nPassword[$NumA]))
$SPassword[$NumF] = DllStructGetData($2Bytes,1,1)
$NumF += 1
$SPassword[$NumF] = DllStructGetData($2Bytes,1,2)
$NumF += 1
Next

$SPassword[0] = $NumE

if $ySize = 1 Then

$yByteA = DllStructGetData($DataStructA,1,1) + 1

$yByteA = BitxOR($SPassword[1],$yByteA)

DllStructSetData($DataStructA,1,$yByteA - 1,1)

Else

$NumB = Mod($ySize - 1,$SPassword[0])
if $NumB = 0 Then $NumB = $SPassword[0]

$yByteA = DllStructGetData($DataStructA,1,1) + 1

For $NumC = $ySize To 2 Step -1
$yByteB = DllStructGetData($DataStructA,1,$NumC) + 1
For $NumD = 1 To $SPassword[$NumB] + 1
$ByArray = GByGet($yByteA,$yByteB)
$yByteA = $ByArray[0]
$yByteB = $ByArray[1]
$yByteB = yByGet($yByteB)
Next
$NumB -= 1
DllStructSetData($DataStructA,1,$yByteB - 1,$NumC)
if $NumB = 0 Then $NumB = $SPassword[0]
Next

DllStructSetData($DataStructA,1,$yByteA - 1,1)

EndIf

Return True

EndFunc

Func DataEncrypt($Password,$DataStructB)

if IsDllStruct($DataStructB) = 0 Or StringLen($Password) = 0 Then Return False

$ySize = DllStructGetSize($DataStructB)

$DataStructA = DllStructCreate("Byte[" &  $ySize & "]",DllStructGetPtr($DataStructB))

$nPassword = StringSplit($Password,"")
$2Bytes  =  DllStructCreate("Byte[2]")

Local $NumE = $nPassword[0] * 2 , $NumF = 1 , $SPassword[$NumE + 1]

For $NumA = 1 To $nPassword[0]
DllStructSetData($2Bytes,1,AscW($nPassword[$NumA]))
$SPassword[$NumF] = DllStructGetData($2Bytes,1,1)
$NumF += 1
$SPassword[$NumF] = DllStructGetData($2Bytes,1,2)
$NumF += 1
Next

$SPassword[0] = $NumE

if $ySize = 1 Then

$yByteA = DllStructGetData($DataStructA,1,1) + 1

$yByteA = BitxOR($yByteA,$SPassword[1])

DllStructSetData($DataStructA,1,$yByteA - 1,1)

Else

$yByteA = DllStructGetData($DataStructA,1,1) + 1

$NumB = 0

For $NumC = 2 To $ySize
$NumB += 1
$yByteB = DllStructGetData($DataStructA,1,$NumC) + 1
For $NumD = 1 To $SPassword[$NumB] + 1
$yByteB = yBySet($yByteB)
$ByArray = GBySet($yByteA,$yByteB)
$yByteA = $ByArray[0]
$yByteB = $ByArray[1]
Next
DllStructSetData($DataStructA,1,$yByteB - 1,$NumC)
if $NumB = $SPassword[0] Then $NumB = 0
Next

DllStructSetData($DataStructA,1,$yByteA - 1,1)

EndIf

Return True

EndFunc


Func yByGet($vByteA)

Local $ByArray[2] , $bByteA , $bByteB

$aByArray = NumGet($vByteA,16,16)
$ByteA = $aByArray[0]
$ByteB = $aByArray[1]

$cByteA = $ByteA
$cByteB = $ByteB

Select
Case $ByteB = 1

$bBySet = 0
$bBySet += ($cByteB - 1) * 16
$bBySet += $cByteA

$cByArray = NumGet($bBySet,4,4)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = $aByteA
$bByteB = $aByteB

Case $ByteB < 11

$cByteB -= 1

$bBySet = 0
$bBySet += ($cByteB - 1) * 16
$bBySet += $cByteA

$cByArray = NumGet($bBySet,12,12)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = ($aByteA + 4)
$bByteB = ($aByteB + 4)

Case $ByteB < 14

$cByteB -= 10

$bBySet = 0
$bBySet += ($cByteB - 1) * 16
$bBySet += $cByteA

$cByArray = NumGet($bBySet,12,4)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA =  $aByteB
$bByteB = ($aByteA + 4)

Case $ByteB < 17

$cByteB -= 13

$bBySet = 0
$bBySet += ($cByteB - 1) * 16
$bBySet += $cByteA

$cByArray = NumGet($bBySet,12,4)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = ($aByteA + 4)
$bByteB = $aByteB

EndSelect

$bBySet = 0
$bBySet += ($bByteB - 1) * 16
$bBySet += $bByteA

Return $bBySet

EndFunc

Func yBySet($vByteA)

Local $bByteA , $bByteB

$aByArray = NumGet($vByteA,16,16)
$ByteA = $aByArray[0]
$ByteB = $aByArray[1]

Select
Case $ByteA < 5 And $ByteB < 5

$cByteA = $ByteA
$cByteB = $ByteB

$bBySet = 0
$bBySet += ($cByteB - 1) * 4
$bBySet += $cByteA

$cByArray = NumGet($bBySet,16,16)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = $aByteA
$bByteB = $aByteB

Case $ByteA > 4 And $ByteB > 4

$cByteA = ($ByteA - 4)
$cByteB = ($ByteB - 4)

$bBySet = 0
$bBySet += ($cByteB - 1) * 12
$bBySet += $cByteA

$cByArray = NumGet($bBySet,16,16)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1] + 1

$bByteA = $aByteA
$bByteB = $aByteB

Case ($ByteA < 5 And $ByteB > 4)

$cByteA =  $ByteA
$cByteB = ($ByteB - 4)

$bBySet = 0
$bBySet += ($cByteA - 1) * 12
$bBySet += $cByteB

$cByArray = NumGet($bBySet,16,16)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1] + 10

$bByteA = $aByteA
$bByteB = $aByteB

Case ($ByteA > 4 And $ByteB < 5)

$cByteB =  $ByteB
$cByteA = ($ByteA - 4)

$bBySet = 0
$bBySet += ($cByteB - 1) * 12
$bBySet += $cByteA

$cByArray = NumGet($bBySet,16,16)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1] + 13

$bByteA = $aByteA
$bByteB = $aByteB

EndSelect

$bBySet = 0
$bBySet += ($bByteB - 1) * 16
$bBySet += $bByteA

Return $bBySet

EndFunc


Func GBySet($ByteA,$ByteB)

Local $ByArray[2] , $bByteA , $bByteB

Select
Case $ByteA < 65 And $ByteB < 65

$cByteA = $ByteA
$cByteB = $ByteB

$bBySet = 0
$bBySet += ($cByteB - 1) * 64
$bBySet += $cByteA

$cByArray = NumGet($bBySet,256,256)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = $aByteA
$bByteB = $aByteB

Case $ByteA > 64 And $ByteB > 64

$cByteA = ($ByteA - 64)
$cByteB = ($ByteB - 64)

$bBySet = 0
$bBySet += ($cByteB - 1) * 192
$bBySet += $cByteA

$cByArray = NumGet($bBySet,256,256)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1] + 16

$bByteA = $aByteA
$bByteB = $aByteB

Case ($ByteA < 65 And $ByteB > 64)

$cByteA =  $ByteA
$cByteB = ($ByteB - 64)

$bBySet = 0
$bBySet += ($cByteA - 1) * 192
$bBySet += $cByteB

$cByArray = NumGet($bBySet,256,256)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1] + 16 + 144

$bByteA = $aByteA
$bByteB = $aByteB

Case ($ByteA > 64 And $ByteB < 65)

$cByteB =  $ByteB
$cByteA = ($ByteA - 64)

$bBySet = 0
$bBySet += ($cByteB - 1) * 192
$bBySet += $cByteA

$cByArray = NumGet($bBySet,256,256)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1] + 16 + 144 + 48

$bByteA = $aByteA
$bByteB = $aByteB

EndSelect

$ByArray[0] = $bByteA
$ByArray[1] = $bByteB

Return $ByArray

EndFunc


Func GByGet($ByteA,$ByteB)

Local $ByArray[2] , $bByteA , $bByteB

$cByteA = $ByteA
$cByteB = $ByteB

Select
Case $ByteB < 17

$bBySet = 0
$bBySet += ($cByteB - 1) * 256
$bBySet += $cByteA

$cByArray = NumGet($bBySet,64,64)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = $aByteA
$bByteB = $aByteB

Case $ByteB < 161

$cByteB -= 16

$bBySet = 0
$bBySet += ($cByteB - 1) * 256
$bBySet += $cByteA

$cByArray = NumGet($bBySet,192,192)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = ($aByteA + 64)
$bByteB = ($aByteB + 64)

Case $ByteB < 209

$cByteB -= 160

$bBySet = 0
$bBySet += ($cByteB - 1) * 256
$bBySet += $cByteA

$cByArray = NumGet($bBySet,192,64)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA =  $aByteB
$bByteB = ($aByteA + 64)

Case $ByteB < 257

$cByteB -= 208

$bBySet = 0
$bBySet += ($cByteB - 1) * 256
$bBySet += $cByteA

$cByArray = NumGet($bBySet,192,64)
$aByteA = $cByArray[0]
$aByteB = $cByArray[1]

$bByteA = ($aByteA + 64)
$bByteB = $aByteB

EndSelect

$ByArray[0] = $bByteA
$ByArray[1] = $bByteB

Return $ByArray

EndFunc


Func NumGet($NuSet,$MaxA,$MaxB,$MaxC = 1,$MaxD = 1,$MaxE = 1,$MaxF = 1,$MaxG = 1,$MaxH = 1)

if $NuSet = 1 Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1
$NuB = 1
$NuA = 1

Else
if $NuSet <= $MaxA Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1
$NuB = 1
$NuA = $NuSet

Else
if $NuSet <= ($MaxA * $MaxB) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1
$NuC = 1

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1
$NuD = 1

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD) Then

$NuH = 1
$NuG = 1
$NuF = 1
$NuE = 1

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE) Then

$NuH = 1
$NuG = 1
$NuF = 1

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF) Then

$NuH = 1
$NuG = 1

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else
if $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG) Then

$NuH = 1

$NuG = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
$vMod = $NuG
$NuG = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
if Not $NuG Then $NuG = $MaxG

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

Else

$NuH = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG * $MaxH))
$vMod = $NuH
$NuH = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)) Then $NuH += 1
if Not $NuH Then $NuH = $MaxH

$NuG = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
$vMod = $NuG
$NuG = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
if Not $NuG Then $NuG = $MaxG

$NuF = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
$vMod = $NuF
$NuF = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
if Not $NuF Then $NuF = $MaxF

$NuE = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
$vMod = $NuE
$NuE = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
if Mod($vMod,($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
if Not $NuE Then $NuE = $MaxE

$NuD = Mod($NuSet,($MaxA * $MaxB * $MaxC * $MaxD))
$vMod = $NuD
$NuD = ($vMod - Mod($vMod,($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
if Mod($vMod,($MaxA * $MaxB * $MaxC)) Then $NuD += 1
if Not $NuD Then $NuD = $MaxD

$NuC = Mod($NuSet,($MaxA * $MaxB * $MaxC))
$vMod = $NuC
$NuC = ($vMod - Mod($vMod,($MaxA * $MaxB))) / ($MaxA * $MaxB)
if Mod($vMod,($MaxA * $MaxB)) Then $NuC += 1
if Not $NuC Then $NuC = $MaxC

$NuB = Mod($NuSet,($MaxA * $MaxB))
$vMod = $NuB
$NuB = ($vMod - Mod($vMod,$MaxA)) / $MaxA
if Mod($vMod,$MaxA) Then $NuB += 1
if Not $NuB Then $NuB = $MaxB

$NuA =  Mod($NuSet,$MaxA)
if Not $NuA Then $NuA = $MaxA

EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf

Dim $NusAry[8]
$NusAry[0] = $NuA
$NusAry[1] = $NuB
$NusAry[2] = $NuC
$NusAry[3] = $NuD
$NusAry[4] = $NuE
$NusAry[5] = $NuF
$NusAry[6] = $NuG
$NusAry[7] = $NuH

Return $NusAry

EndFunc

 

Edited by wolf9228

صرح السماء كان هنا

 

Link to post
Share on other sites

AutoIt uses UCS2 encoding, so when converted to a bunch of char in a structure, Unicode to ANSI conversion is applied, destroying the plaintext before it's even "encrypted". Same for the use of Asc in lieu of AscW and Chr instead of ChrW.

BTW, which algorithm do you use, or is it homebrew?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
11 hours ago, jchd said:

AutoIt uses UCS2 encoding, so when converted to a bunch of char in a structure, Unicode to ANSI conversion is applied, destroying the plaintext before it's even "encrypted". Same for the use of Asc in lieu of AscW and Chr instead of ChrW.

BTW, which algorithm do you use, or is it homebrew?

 

Thank you, the code has been modified ... and the use of the Ascw function

صرح السماء كان هنا

 

Link to post
Share on other sites

Fine. My other question remains: which algorithm do you use, or is it homebrew?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
Posted (edited)
8 hours ago, jchd said:

Fine. My other question remains: which algorithm do you use, or is it homebrew?


 

The algorithms from a project belonging to me until now I have not finished it ... it is in the context of data compression, but the idea of the project is fictional compressing any data of any size to a fixed size ... from infinity and to a constant The idea seems fictional until now I am working on the code. .. Thank you.

Edited by wolf9228

صرح السماء كان هنا

 

Link to post
Share on other sites
8 hours ago, jchd said:

Fine. My other question remains: which algorithm do you use, or is it homebrew?

You do not believe what I say. Certainly what I said is not sarcasm. I will clarify a bit. The idea depends on breaking the mathematical probability rule. If assuming we have two bytes, the result of the two probabilities is equal to 256 * 256 and the number of possibilities cannot exceed that and how can this rule be broken I'm sure This is possible, but in a large number of bytes, for example in 256 bytes, that is, a group of bytes equals 256 bytes, by using both logical and mathematical operations at the same time, the result of the 256 bytes is 256 to the power of 256 ... Thanks.

صرح السماء كان هنا

 

Link to post
Share on other sites

The version is easier to use:

Global $iData = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Global $iPassword = "XXX"

Local $iLog_1 = "- Input: " & $iData & @CRLF
ConsoleWrite($iLog_1)
Local $iLog_2 = "- Password: " & $iPassword & @CRLF
ConsoleWrite($iLog_2)
Global $Data_Encrypted = sData_Encrypt($iData, $iPassword)
Local $iLog_3 = "- Encrypt: " & $Data_Encrypted & @CRLF
ConsoleWrite($iLog_3)
Global $Data_Decrypted = sData_Decrypt($Data_Encrypted, $iPassword)
Local $iLog_4 = "- Decrypt: " & $Data_Decrypted & @CRLF
ConsoleWrite($iLog_4)
Local $iLog_5 = ($Data_Decrypted == $iData) ? "+ Test OK" & @CRLF : "! Test Faild" & @CRLF
ConsoleWrite($iLog_5)
MsgBox(0, "Data En/Decrypted: " & $iLog_5, $iLog_1 & $iLog_2 & $iLog_3 & $iLog_4)

; #CURRENT# =====================================================================================================================
Func sData_Decrypt($sData, $Password = 'TRONG.LIVE')
    Local $DataLen = StringLen($sData)
    Local $DataSt = DllStructCreate("char[" & $DataLen & "]")
    DllStructSetData($DataSt, 1, $sData)
    If IsDllStruct($DataSt) = 0 Or StringLen($Password) = 0 Then Return False
    Local $ySize = DllStructGetSize($DataSt)
    Local $DataStructA = DllStructCreate("Byte[" & $ySize & "]", DllStructGetPtr($DataSt))
    Local $nPassword = StringSplit($Password, "")
    Local $2Bytes = DllStructCreate("Byte[2]")
    Local $NumE = $nPassword[0] * 2, $NumF = 1, $SPassword[$NumE + 1]
    For $NumA = 1 To $nPassword[0]
        DllStructSetData($2Bytes, 1, AscW($nPassword[$NumA]))
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 1)
        $NumF += 1
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 2)
        $NumF += 1
    Next
    $SPassword[0] = $NumE
    Local $yByteA, $yByteB, $NumB
    If $ySize = 1 Then
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        $yByteA = BitXOR($SPassword[0], $yByteA)
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    Else
        $NumB = Mod($ySize - 1, $SPassword[0])
        If $NumB = 0 Then $NumB = $SPassword[0]
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        For $NumC = $ySize To 2 Step -1
            $yByteB = DllStructGetData($DataStructA, 1, $NumC) + 1
            For $NumD = 1 To $SPassword[$NumB] + 1
                Local $ByArray = sData_GByGet($yByteA, $yByteB)
                $yByteA = $ByArray[0]
                $yByteB = $ByArray[1]
                $yByteB = sData_yByGet($yByteB)
            Next
            $NumB -= 1
            DllStructSetData($DataStructA, 1, $yByteB - 1, $NumC)
            If $NumB = 0 Then $NumB = $SPassword[0]
        Next
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    EndIf
    Return DllStructGetData($DataSt, 1)
EndFunc   ;==>sData_Decrypt
Func sData_Encrypt($sData, $Password = 'TRONG.LIVE')
    Local $DataLen = StringLen($sData)
    Local $DataSt = DllStructCreate("char[" & $DataLen & "]")
    DllStructSetData($DataSt, 1, $sData)
    If IsDllStruct($DataSt) = 0 Or StringLen($Password) = 0 Then Return False
    Local $ySize = DllStructGetSize($DataSt)
    Local $DataStructA = DllStructCreate("Byte[" & $ySize & "]", DllStructGetPtr($DataSt))
    Local $nPassword = StringSplit($Password, "")
    Local $2Bytes = DllStructCreate("Byte[2]")
    Local $NumE = $nPassword[0] * 2, $NumF = 1, $SPassword[$NumE + 1]
    For $NumA = 1 To $nPassword[0]
        DllStructSetData($2Bytes, 1, AscW($nPassword[$NumA]))
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 1)
        $NumF += 1
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 2)
        $NumF += 1
    Next
    $SPassword[0] = $NumE
    Local $yByteA, $NumB, $yByteB
    If $ySize = 1 Then
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        $yByteA = BitXOR($yByteA, $SPassword[0])
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    Else
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        $NumB = 0
        For $NumC = 2 To $ySize
            $NumB += 1
            $yByteB = DllStructGetData($DataStructA, 1, $NumC) + 1
            For $NumD = 1 To $SPassword[$NumB] + 1
                $yByteB = sData_yBySet($yByteB)
                Local $ByArray = sData_GBySet($yByteA, $yByteB)
                $yByteA = $ByArray[0]
                $yByteB = $ByArray[1]
            Next
            DllStructSetData($DataStructA, 1, $yByteB - 1, $NumC)
            If $NumB = $SPassword[0] Then $NumB = 0
        Next
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    EndIf
    Return DllStructGetData($DataSt, 1)
EndFunc   ;==>sData_Encrypt
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
Func sData_yByGet($vByteA)
    Local $ByArray[2], $bByteA, $bByteB
    Local $aByArray = sData_NumGet($vByteA, 16, 16)
    Local $ByteA = $aByArray[0]
    Local $ByteB = $aByArray[1]
    Local $cByteA = $ByteA
    Local $cByteB = $ByteB
    Local $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteB = 1
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 4, 4)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteB < 11
            $cByteB -= 1
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 12, 12)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 4)
            $bByteB = ($aByteB + 4)
        Case $ByteB < 14
            $cByteB -= 10
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 12, 4)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteB
            $bByteB = ($aByteA + 4)
        Case $ByteB < 17
            $cByteB -= 13
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 12, 4)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 4)
            $bByteB = $aByteB
    EndSelect
    $bBySet = 0
    $bBySet += ($bByteB - 1) * 16
    $bBySet += $bByteA
    Return $bBySet
EndFunc   ;==>sData_yByGet
Func sData_yBySet($vByteA)
    Local $bByteA, $bByteB
    Local $aByArray = sData_NumGet($vByteA, 16, 16)
    Local $ByteA = $aByArray[0]
    Local $ByteB = $aByArray[1]
    Local $cByteA, $cByteB, $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteA < 5 And $ByteB < 5
            $cByteA = $ByteA
            $cByteB = $ByteB
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 4
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteA > 4 And $ByteB > 4
            $cByteA = ($ByteA - 4)
            $cByteB = ($ByteB - 4)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 12
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 1
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA < 5 And $ByteB > 4)
            $cByteA = $ByteA
            $cByteB = ($ByteB - 4)
            $bBySet = 0
            $bBySet += ($cByteA - 1) * 12
            $bBySet += $cByteB
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 10
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA > 4 And $ByteB < 5)
            $cByteB = $ByteB
            $cByteA = ($ByteA - 4)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 12
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 13
            $bByteA = $aByteA
            $bByteB = $aByteB
    EndSelect
    $bBySet = 0
    $bBySet += ($bByteB - 1) * 16
    $bBySet += $bByteA
    Return $bBySet
EndFunc   ;==>sData_yBySet
Func sData_GBySet($ByteA, $ByteB)
    Local $ByArray[2], $bByteA, $bByteB, $cByteA, $cByteB, $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteA < 65 And $ByteB < 65
            $cByteA = $ByteA
            $cByteB = $ByteB
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 64
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteA > 64 And $ByteB > 64
            $cByteA = ($ByteA - 64)
            $cByteB = ($ByteB - 64)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 192
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 16
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA < 65 And $ByteB > 64)
            $cByteA = $ByteA
            $cByteB = ($ByteB - 64)
            $bBySet = 0
            $bBySet += ($cByteA - 1) * 192
            $bBySet += $cByteB
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 16 + 144
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA > 64 And $ByteB < 65)
            $cByteB = $ByteB
            $cByteA = ($ByteA - 64)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 192
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 16 + 144 + 48
            $bByteA = $aByteA
            $bByteB = $aByteB
    EndSelect
    $ByArray[0] = $bByteA
    $ByArray[1] = $bByteB
    Return $ByArray
EndFunc   ;==>sData_GBySet
Func sData_GByGet($ByteA, $ByteB)
    Local $ByArray[2], $bByteA, $bByteB
    Local $cByteA = $ByteA
    Local $cByteB = $ByteB
    Local $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteB < 17
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 64, 64)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteB < 161
            $cByteB -= 16
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 192, 192)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 64)
            $bByteB = ($aByteB + 64)
        Case $ByteB < 209
            $cByteB -= 160
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 192, 64)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteB
            $bByteB = ($aByteA + 64)
        Case $ByteB < 257
            $cByteB -= 208
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 192, 64)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 64)
            $bByteB = $aByteB
    EndSelect
    $ByArray[0] = $bByteA
    $ByArray[1] = $bByteB
    Return $ByArray
EndFunc   ;==>sData_GByGet
Func sData_NumGet($NuSet, $MaxA, $MaxB, $MaxC = 1, $MaxD = 1, $MaxE = 1, $MaxF = 1, $MaxG = 1, $MaxH = 1)
    Local $vMod, $NuH, $NuG, $NuF, $NuE, $NuD, $NuC, $NuB, $NuA
    If $NuSet = 1 Then
        $NuH = 1
        $NuG = 1
        $NuF = 1
        $NuE = 1
        $NuD = 1
        $NuC = 1
        $NuB = 1
        $NuA = 1
    Else
        If $NuSet <= $MaxA Then
            $NuH = 1
            $NuG = 1
            $NuF = 1
            $NuE = 1
            $NuD = 1
            $NuC = 1
            $NuB = 1
            $NuA = $NuSet
        Else
            If $NuSet <= ($MaxA * $MaxB) Then
                $NuH = 1
                $NuG = 1
                $NuF = 1
                $NuE = 1
                $NuD = 1
                $NuC = 1
                $NuB = Mod($NuSet, ($MaxA * $MaxB))
                $vMod = $NuB
                $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                If Mod($vMod, $MaxA) Then $NuB += 1
                If Not $NuB Then $NuB = $MaxB
                $NuA = Mod($NuSet, $MaxA)
                If Not $NuA Then $NuA = $MaxA
            Else
                If $NuSet <= ($MaxA * $MaxB * $MaxC) Then
                    $NuH = 1
                    $NuG = 1
                    $NuF = 1
                    $NuE = 1
                    $NuD = 1
                    $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                    $vMod = $NuC
                    $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                    If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                    If Not $NuC Then $NuC = $MaxC
                    $NuB = Mod($NuSet, ($MaxA * $MaxB))
                    $vMod = $NuB
                    $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                    If Mod($vMod, $MaxA) Then $NuB += 1
                    If Not $NuB Then $NuB = $MaxB
                    $NuA = Mod($NuSet, $MaxA)
                    If Not $NuA Then $NuA = $MaxA
                Else
                    If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD) Then
                        $NuH = 1
                        $NuG = 1
                        $NuF = 1
                        $NuE = 1
                        $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                        $vMod = $NuD
                        $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                        If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                        If Not $NuD Then $NuD = $MaxD
                        $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                        $vMod = $NuC
                        $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                        If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                        If Not $NuC Then $NuC = $MaxC
                        $NuB = Mod($NuSet, ($MaxA * $MaxB))
                        $vMod = $NuB
                        $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                        If Mod($vMod, $MaxA) Then $NuB += 1
                        If Not $NuB Then $NuB = $MaxB
                        $NuA = Mod($NuSet, $MaxA)
                        If Not $NuA Then $NuA = $MaxA
                    Else
                        If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE) Then
                            $NuH = 1
                            $NuG = 1
                            $NuF = 1
                            $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                            $vMod = $NuE
                            $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                            If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                            If Not $NuE Then $NuE = $MaxE
                            $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                            $vMod = $NuD
                            $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                            If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                            If Not $NuD Then $NuD = $MaxD
                            $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                            $vMod = $NuC
                            $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                            If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                            If Not $NuC Then $NuC = $MaxC
                            $NuB = Mod($NuSet, ($MaxA * $MaxB))
                            $vMod = $NuB
                            $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                            If Mod($vMod, $MaxA) Then $NuB += 1
                            If Not $NuB Then $NuB = $MaxB
                            $NuA = Mod($NuSet, $MaxA)
                            If Not $NuA Then $NuA = $MaxA
                        Else
                            If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF) Then
                                $NuH = 1
                                $NuG = 1
                                $NuF = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
                                $vMod = $NuF
                                $NuF = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
                                If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
                                If Not $NuF Then $NuF = $MaxF
                                $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                                $vMod = $NuE
                                $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                                If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                                If Not $NuE Then $NuE = $MaxE
                                $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                                $vMod = $NuD
                                $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                                If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                                If Not $NuD Then $NuD = $MaxD
                                $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                                $vMod = $NuC
                                $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                                If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                                If Not $NuC Then $NuC = $MaxC
                                $NuB = Mod($NuSet, ($MaxA * $MaxB))
                                $vMod = $NuB
                                $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                                If Mod($vMod, $MaxA) Then $NuB += 1
                                If Not $NuB Then $NuB = $MaxB
                                $NuA = Mod($NuSet, $MaxA)
                                If Not $NuA Then $NuA = $MaxA
                            Else
                                If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG) Then
                                    $NuH = 1
                                    $NuG = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
                                    $vMod = $NuG
                                    $NuG = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
                                    If Not $NuG Then $NuG = $MaxG
                                    $NuF = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
                                    $vMod = $NuF
                                    $NuF = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
                                    If Not $NuF Then $NuF = $MaxF
                                    $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                                    $vMod = $NuE
                                    $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                                    If Not $NuE Then $NuE = $MaxE
                                    $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                                    $vMod = $NuD
                                    $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                                    If Not $NuD Then $NuD = $MaxD
                                    $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                                    $vMod = $NuC
                                    $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                                    If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                                    If Not $NuC Then $NuC = $MaxC
                                    $NuB = Mod($NuSet, ($MaxA * $MaxB))
                                    $vMod = $NuB
                                    $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                                    If Mod($vMod, $MaxA) Then $NuB += 1
                                    If Not $NuB Then $NuB = $MaxB
                                    $NuA = Mod($NuSet, $MaxA)
                                    If Not $NuA Then $NuA = $MaxA
                                Else
                                    $NuH = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG * $MaxH))
                                    $vMod = $NuH
                                    $NuH = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)) Then $NuH += 1
                                    If Not $NuH Then $NuH = $MaxH
                                    $NuG = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
                                    $vMod = $NuG
                                    $NuG = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
                                    If Not $NuG Then $NuG = $MaxG
                                    $NuF = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
                                    $vMod = $NuF
                                    $NuF = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
                                    If Not $NuF Then $NuF = $MaxF
                                    $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                                    $vMod = $NuE
                                    $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                                    If Not $NuE Then $NuE = $MaxE
                                    $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                                    $vMod = $NuD
                                    $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                                    If Not $NuD Then $NuD = $MaxD
                                    $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                                    $vMod = $NuC
                                    $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                                    If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                                    If Not $NuC Then $NuC = $MaxC
                                    $NuB = Mod($NuSet, ($MaxA * $MaxB))
                                    $vMod = $NuB
                                    $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                                    If Mod($vMod, $MaxA) Then $NuB += 1
                                    If Not $NuB Then $NuB = $MaxB
                                    $NuA = Mod($NuSet, $MaxA)
                                    If Not $NuA Then $NuA = $MaxA
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    Dim $NusAry[8]
    $NusAry[0] = $NuA
    $NusAry[1] = $NuB
    $NusAry[2] = $NuC
    $NusAry[3] = $NuD
    $NusAry[4] = $NuE
    $NusAry[5] = $NuF
    $NusAry[6] = $NuG
    $NusAry[7] = $NuH
    Return $NusAry
EndFunc   ;==>sData_NumGet
; ===============================================================================================================================

 

Edited by VIP
It does not support unicode

Regards,
 

Link to post
Share on other sites
3 hours ago, VIP said:

The version is easier to use:

Global $iData = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Global $iPassword = "XXX"

Local $iLog_1 = "- Input: " & $iData & @CRLF
ConsoleWrite($iLog_1)
Local $iLog_2 = "- Password: " & $iPassword & @CRLF
ConsoleWrite($iLog_2)
Global $Data_Encrypted = sData_Encrypt($iData, $iPassword)
Local $iLog_3 = "- Encrypt: " & $Data_Encrypted & @CRLF
ConsoleWrite($iLog_3)
Global $Data_Decrypted = sData_Decrypt($Data_Encrypted, $iPassword)
Local $iLog_4 = "- Decrypt: " & $Data_Decrypted & @CRLF
ConsoleWrite($iLog_4)
Local $iLog_5 = ($Data_Decrypted == $iData) ? "+ Test OK" & @CRLF : "! Test Faild" & @CRLF
ConsoleWrite($iLog_5)
MsgBox(0, "Data En/Decrypted: " & $iLog_5, $iLog_1 & $iLog_2 & $iLog_3 & $iLog_4)

; #CURRENT# =====================================================================================================================
Func sData_Decrypt($sData, $Password = 'TRONG.LIVE')
    Local $DataLen = StringLen($sData)
    Local $DataSt = DllStructCreate("char[" & $DataLen & "]")
    DllStructSetData($DataSt, 1, $sData)
    If IsDllStruct($DataSt) = 0 Or StringLen($Password) = 0 Then Return False
    Local $ySize = DllStructGetSize($DataSt)
    Local $DataStructA = DllStructCreate("Byte[" & $ySize & "]", DllStructGetPtr($DataSt))
    Local $nPassword = StringSplit($Password, "")
    Local $2Bytes = DllStructCreate("Byte[2]")
    Local $NumE = $nPassword[0] * 2, $NumF = 1, $SPassword[$NumE + 1]
    For $NumA = 1 To $nPassword[0]
        DllStructSetData($2Bytes, 1, AscW($nPassword[$NumA]))
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 1)
        $NumF += 1
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 2)
        $NumF += 1
    Next
    $SPassword[0] = $NumE
    Local $yByteA, $yByteB, $NumB
    If $ySize = 1 Then
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        $yByteA = BitXOR($SPassword[0], $yByteA)
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    Else
        $NumB = Mod($ySize - 1, $SPassword[0])
        If $NumB = 0 Then $NumB = $SPassword[0]
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        For $NumC = $ySize To 2 Step -1
            $yByteB = DllStructGetData($DataStructA, 1, $NumC) + 1
            For $NumD = 1 To $SPassword[$NumB] + 1
                Local $ByArray = sData_GByGet($yByteA, $yByteB)
                $yByteA = $ByArray[0]
                $yByteB = $ByArray[1]
                $yByteB = sData_yByGet($yByteB)
            Next
            $NumB -= 1
            DllStructSetData($DataStructA, 1, $yByteB - 1, $NumC)
            If $NumB = 0 Then $NumB = $SPassword[0]
        Next
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    EndIf
    Return DllStructGetData($DataSt, 1)
EndFunc   ;==>sData_Decrypt
Func sData_Encrypt($sData, $Password = 'TRONG.LIVE')
    Local $DataLen = StringLen($sData)
    Local $DataSt = DllStructCreate("char[" & $DataLen & "]")
    DllStructSetData($DataSt, 1, $sData)
    If IsDllStruct($DataSt) = 0 Or StringLen($Password) = 0 Then Return False
    Local $ySize = DllStructGetSize($DataSt)
    Local $DataStructA = DllStructCreate("Byte[" & $ySize & "]", DllStructGetPtr($DataSt))
    Local $nPassword = StringSplit($Password, "")
    Local $2Bytes = DllStructCreate("Byte[2]")
    Local $NumE = $nPassword[0] * 2, $NumF = 1, $SPassword[$NumE + 1]
    For $NumA = 1 To $nPassword[0]
        DllStructSetData($2Bytes, 1, AscW($nPassword[$NumA]))
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 1)
        $NumF += 1
        $SPassword[$NumF] = DllStructGetData($2Bytes, 1, 2)
        $NumF += 1
    Next
    $SPassword[0] = $NumE
    Local $yByteA, $NumB, $yByteB
    If $ySize = 1 Then
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        $yByteA = BitXOR($yByteA, $SPassword[0])
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    Else
        $yByteA = DllStructGetData($DataStructA, 1, 1) + 1
        $NumB = 0
        For $NumC = 2 To $ySize
            $NumB += 1
            $yByteB = DllStructGetData($DataStructA, 1, $NumC) + 1
            For $NumD = 1 To $SPassword[$NumB] + 1
                $yByteB = sData_yBySet($yByteB)
                Local $ByArray = sData_GBySet($yByteA, $yByteB)
                $yByteA = $ByArray[0]
                $yByteB = $ByArray[1]
            Next
            DllStructSetData($DataStructA, 1, $yByteB - 1, $NumC)
            If $NumB = $SPassword[0] Then $NumB = 0
        Next
        DllStructSetData($DataStructA, 1, $yByteA - 1, 1)
    EndIf
    Return DllStructGetData($DataSt, 1)
EndFunc   ;==>sData_Encrypt
; ===============================================================================================================================

; #INTERNAL_USE_ONLY# ===========================================================================================================
Func sData_yByGet($vByteA)
    Local $ByArray[2], $bByteA, $bByteB
    Local $aByArray = sData_NumGet($vByteA, 16, 16)
    Local $ByteA = $aByArray[0]
    Local $ByteB = $aByArray[1]
    Local $cByteA = $ByteA
    Local $cByteB = $ByteB
    Local $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteB = 1
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 4, 4)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteB < 11
            $cByteB -= 1
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 12, 12)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 4)
            $bByteB = ($aByteB + 4)
        Case $ByteB < 14
            $cByteB -= 10
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 12, 4)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteB
            $bByteB = ($aByteA + 4)
        Case $ByteB < 17
            $cByteB -= 13
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 16
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 12, 4)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 4)
            $bByteB = $aByteB
    EndSelect
    $bBySet = 0
    $bBySet += ($bByteB - 1) * 16
    $bBySet += $bByteA
    Return $bBySet
EndFunc   ;==>sData_yByGet
Func sData_yBySet($vByteA)
    Local $bByteA, $bByteB
    Local $aByArray = sData_NumGet($vByteA, 16, 16)
    Local $ByteA = $aByArray[0]
    Local $ByteB = $aByArray[1]
    Local $cByteA, $cByteB, $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteA < 5 And $ByteB < 5
            $cByteA = $ByteA
            $cByteB = $ByteB
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 4
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteA > 4 And $ByteB > 4
            $cByteA = ($ByteA - 4)
            $cByteB = ($ByteB - 4)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 12
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 1
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA < 5 And $ByteB > 4)
            $cByteA = $ByteA
            $cByteB = ($ByteB - 4)
            $bBySet = 0
            $bBySet += ($cByteA - 1) * 12
            $bBySet += $cByteB
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 10
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA > 4 And $ByteB < 5)
            $cByteB = $ByteB
            $cByteA = ($ByteA - 4)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 12
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 16, 16)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 13
            $bByteA = $aByteA
            $bByteB = $aByteB
    EndSelect
    $bBySet = 0
    $bBySet += ($bByteB - 1) * 16
    $bBySet += $bByteA
    Return $bBySet
EndFunc   ;==>sData_yBySet
Func sData_GBySet($ByteA, $ByteB)
    Local $ByArray[2], $bByteA, $bByteB, $cByteA, $cByteB, $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteA < 65 And $ByteB < 65
            $cByteA = $ByteA
            $cByteB = $ByteB
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 64
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteA > 64 And $ByteB > 64
            $cByteA = ($ByteA - 64)
            $cByteB = ($ByteB - 64)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 192
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 16
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA < 65 And $ByteB > 64)
            $cByteA = $ByteA
            $cByteB = ($ByteB - 64)
            $bBySet = 0
            $bBySet += ($cByteA - 1) * 192
            $bBySet += $cByteB
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 16 + 144
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case ($ByteA > 64 And $ByteB < 65)
            $cByteB = $ByteB
            $cByteA = ($ByteA - 64)
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 192
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 256, 256)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1] + 16 + 144 + 48
            $bByteA = $aByteA
            $bByteB = $aByteB
    EndSelect
    $ByArray[0] = $bByteA
    $ByArray[1] = $bByteB
    Return $ByArray
EndFunc   ;==>sData_GBySet
Func sData_GByGet($ByteA, $ByteB)
    Local $ByArray[2], $bByteA, $bByteB
    Local $cByteA = $ByteA
    Local $cByteB = $ByteB
    Local $bBySet, $cByArray, $aByteA, $aByteB
    Select
        Case $ByteB < 17
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 64, 64)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteA
            $bByteB = $aByteB
        Case $ByteB < 161
            $cByteB -= 16
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 192, 192)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 64)
            $bByteB = ($aByteB + 64)
        Case $ByteB < 209
            $cByteB -= 160
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 192, 64)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = $aByteB
            $bByteB = ($aByteA + 64)
        Case $ByteB < 257
            $cByteB -= 208
            $bBySet = 0
            $bBySet += ($cByteB - 1) * 256
            $bBySet += $cByteA
            $cByArray = sData_NumGet($bBySet, 192, 64)
            $aByteA = $cByArray[0]
            $aByteB = $cByArray[1]
            $bByteA = ($aByteA + 64)
            $bByteB = $aByteB
    EndSelect
    $ByArray[0] = $bByteA
    $ByArray[1] = $bByteB
    Return $ByArray
EndFunc   ;==>sData_GByGet
Func sData_NumGet($NuSet, $MaxA, $MaxB, $MaxC = 1, $MaxD = 1, $MaxE = 1, $MaxF = 1, $MaxG = 1, $MaxH = 1)
    Local $vMod, $NuH, $NuG, $NuF, $NuE, $NuD, $NuC, $NuB, $NuA
    If $NuSet = 1 Then
        $NuH = 1
        $NuG = 1
        $NuF = 1
        $NuE = 1
        $NuD = 1
        $NuC = 1
        $NuB = 1
        $NuA = 1
    Else
        If $NuSet <= $MaxA Then
            $NuH = 1
            $NuG = 1
            $NuF = 1
            $NuE = 1
            $NuD = 1
            $NuC = 1
            $NuB = 1
            $NuA = $NuSet
        Else
            If $NuSet <= ($MaxA * $MaxB) Then
                $NuH = 1
                $NuG = 1
                $NuF = 1
                $NuE = 1
                $NuD = 1
                $NuC = 1
                $NuB = Mod($NuSet, ($MaxA * $MaxB))
                $vMod = $NuB
                $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                If Mod($vMod, $MaxA) Then $NuB += 1
                If Not $NuB Then $NuB = $MaxB
                $NuA = Mod($NuSet, $MaxA)
                If Not $NuA Then $NuA = $MaxA
            Else
                If $NuSet <= ($MaxA * $MaxB * $MaxC) Then
                    $NuH = 1
                    $NuG = 1
                    $NuF = 1
                    $NuE = 1
                    $NuD = 1
                    $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                    $vMod = $NuC
                    $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                    If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                    If Not $NuC Then $NuC = $MaxC
                    $NuB = Mod($NuSet, ($MaxA * $MaxB))
                    $vMod = $NuB
                    $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                    If Mod($vMod, $MaxA) Then $NuB += 1
                    If Not $NuB Then $NuB = $MaxB
                    $NuA = Mod($NuSet, $MaxA)
                    If Not $NuA Then $NuA = $MaxA
                Else
                    If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD) Then
                        $NuH = 1
                        $NuG = 1
                        $NuF = 1
                        $NuE = 1
                        $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                        $vMod = $NuD
                        $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                        If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                        If Not $NuD Then $NuD = $MaxD
                        $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                        $vMod = $NuC
                        $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                        If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                        If Not $NuC Then $NuC = $MaxC
                        $NuB = Mod($NuSet, ($MaxA * $MaxB))
                        $vMod = $NuB
                        $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                        If Mod($vMod, $MaxA) Then $NuB += 1
                        If Not $NuB Then $NuB = $MaxB
                        $NuA = Mod($NuSet, $MaxA)
                        If Not $NuA Then $NuA = $MaxA
                    Else
                        If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE) Then
                            $NuH = 1
                            $NuG = 1
                            $NuF = 1
                            $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                            $vMod = $NuE
                            $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                            If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                            If Not $NuE Then $NuE = $MaxE
                            $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                            $vMod = $NuD
                            $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                            If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                            If Not $NuD Then $NuD = $MaxD
                            $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                            $vMod = $NuC
                            $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                            If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                            If Not $NuC Then $NuC = $MaxC
                            $NuB = Mod($NuSet, ($MaxA * $MaxB))
                            $vMod = $NuB
                            $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                            If Mod($vMod, $MaxA) Then $NuB += 1
                            If Not $NuB Then $NuB = $MaxB
                            $NuA = Mod($NuSet, $MaxA)
                            If Not $NuA Then $NuA = $MaxA
                        Else
                            If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF) Then
                                $NuH = 1
                                $NuG = 1
                                $NuF = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
                                $vMod = $NuF
                                $NuF = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
                                If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
                                If Not $NuF Then $NuF = $MaxF
                                $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                                $vMod = $NuE
                                $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                                If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                                If Not $NuE Then $NuE = $MaxE
                                $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                                $vMod = $NuD
                                $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                                If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                                If Not $NuD Then $NuD = $MaxD
                                $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                                $vMod = $NuC
                                $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                                If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                                If Not $NuC Then $NuC = $MaxC
                                $NuB = Mod($NuSet, ($MaxA * $MaxB))
                                $vMod = $NuB
                                $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                                If Mod($vMod, $MaxA) Then $NuB += 1
                                If Not $NuB Then $NuB = $MaxB
                                $NuA = Mod($NuSet, $MaxA)
                                If Not $NuA Then $NuA = $MaxA
                            Else
                                If $NuSet <= ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG) Then
                                    $NuH = 1
                                    $NuG = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
                                    $vMod = $NuG
                                    $NuG = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
                                    If Not $NuG Then $NuG = $MaxG
                                    $NuF = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
                                    $vMod = $NuF
                                    $NuF = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
                                    If Not $NuF Then $NuF = $MaxF
                                    $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                                    $vMod = $NuE
                                    $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                                    If Not $NuE Then $NuE = $MaxE
                                    $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                                    $vMod = $NuD
                                    $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                                    If Not $NuD Then $NuD = $MaxD
                                    $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                                    $vMod = $NuC
                                    $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                                    If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                                    If Not $NuC Then $NuC = $MaxC
                                    $NuB = Mod($NuSet, ($MaxA * $MaxB))
                                    $vMod = $NuB
                                    $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                                    If Mod($vMod, $MaxA) Then $NuB += 1
                                    If Not $NuB Then $NuB = $MaxB
                                    $NuA = Mod($NuSet, $MaxA)
                                    If Not $NuA Then $NuA = $MaxA
                                Else
                                    $NuH = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG * $MaxH))
                                    $vMod = $NuH
                                    $NuH = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG)) Then $NuH += 1
                                    If Not $NuH Then $NuH = $MaxH
                                    $NuG = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF * $MaxG))
                                    $vMod = $NuG
                                    $NuG = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF)) Then $NuG += 1
                                    If Not $NuG Then $NuG = $MaxG
                                    $NuF = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE * $MaxF))
                                    $vMod = $NuF
                                    $NuF = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))) / ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE)) Then $NuF += 1
                                    If Not $NuF Then $NuF = $MaxF
                                    $NuE = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD * $MaxE))
                                    $vMod = $NuE
                                    $NuE = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD))) / ($MaxA * $MaxB * $MaxC * $MaxD)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC * $MaxD)) Then $NuE += 1
                                    If Not $NuE Then $NuE = $MaxE
                                    $NuD = Mod($NuSet, ($MaxA * $MaxB * $MaxC * $MaxD))
                                    $vMod = $NuD
                                    $NuD = ($vMod - Mod($vMod, ($MaxA * $MaxB * $MaxC))) / ($MaxA * $MaxB * $MaxC)
                                    If Mod($vMod, ($MaxA * $MaxB * $MaxC)) Then $NuD += 1
                                    If Not $NuD Then $NuD = $MaxD
                                    $NuC = Mod($NuSet, ($MaxA * $MaxB * $MaxC))
                                    $vMod = $NuC
                                    $NuC = ($vMod - Mod($vMod, ($MaxA * $MaxB))) / ($MaxA * $MaxB)
                                    If Mod($vMod, ($MaxA * $MaxB)) Then $NuC += 1
                                    If Not $NuC Then $NuC = $MaxC
                                    $NuB = Mod($NuSet, ($MaxA * $MaxB))
                                    $vMod = $NuB
                                    $NuB = ($vMod - Mod($vMod, $MaxA)) / $MaxA
                                    If Mod($vMod, $MaxA) Then $NuB += 1
                                    If Not $NuB Then $NuB = $MaxB
                                    $NuA = Mod($NuSet, $MaxA)
                                    If Not $NuA Then $NuA = $MaxA
                                EndIf
                            EndIf
                        EndIf
                    EndIf
                EndIf
            EndIf
        EndIf
    EndIf
    Dim $NusAry[8]
    $NusAry[0] = $NuA
    $NusAry[1] = $NuB
    $NusAry[2] = $NuC
    $NusAry[3] = $NuD
    $NusAry[4] = $NuE
    $NusAry[5] = $NuF
    $NusAry[6] = $NuG
    $NusAry[7] = $NuH
    Return $NusAry
EndFunc   ;==>sData_NumGet
; ===============================================================================================================================

 

The code you created is only valid for chars strings, not for binaries or Wchars strings.
But what you have done is amazing ... Thanks.

صرح السماء كان هنا

 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...