Ich versuche, eine Arbeit in Bash-Scripting zu erreichen. Ich habe eine Zeichenfolge, die ich mit meinem Schlüssel XOR machen möchte.bitweise XOR eine Zeichenfolge in Bash
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
teststring="abcdefghijklmnopqr"
Nun wie XOR den Wert von testring und speichern Sie es in einer Variablen mit bash?
Jede Hilfe wird geschätzt.
Grundsätzlich versuche ich das Ergebnis von follwing VB Script zu kopieren:
Function XOREncryption(CodeKey, DataIn)
Dim lonDataPtr
Dim strDataOut
Dim temp
Dim tempstring
Dim intXOrValue1
Dim intXOrValue2
For lonDataPtr = 1 To Len(DataIn) Step 1
'The first value to be XOr-ed comes from the data to be encrypted
intXOrValue1 = Asc(Mid(DataIn, lonDataPtr, 1))
'The second value comes from the code key
intXOrValue2 = Asc(Mid(CodeKey, ((lonDataPtr Mod Len(CodeKey)) + 1), 1))
temp = (intXOrValue1 Xor intXOrValue2)
tempstring = Hex(temp)
If Len(tempstring) = 1 Then tempstring = "0" & tempstring
strDataOut = strDataOut + tempstring
Next
XOREncryption = strDataOut
End Function
Wäre es nicht einfach "teststring =" abcdefghijklmnopqr "^ key"? –
das dosen; t Arbeit – ricky2002
vielleicht, wenn es eine Möglichkeit gibt, den Wert von testring in Perl von Bash-Skript übergeben und XOR es dort. – ricky2002