Sto provando a realizzare un lavoro nello scripting di Bash. Ho una stringa che voglio XOR con la mia chiave.bit a bit XOR una stringa in Bash
#!/bin/sh
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
teststring="abcdefghijklmnopqr"
Ora come si XOR il valore di teststring e lo si memorizza in una variabile utilizzando bash?
Qualsiasi aiuto sarà apprezzato.
Fondamentalmente sto cercando di duplicare il risultato di follwing VB Script:
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
Non sarebbe solo 'teststring =" abcdefghijklmnopqr "^ chiave'? –
che dosen; t lavoro – ricky2002
forse se c'è un modo per passare il valore di teststring in perl da script bash e XOR lì. – ricky2002