----------------------------------------------------------------------------------
@MSGID: 1@news.xmission.com>
0f02a7e8
@REPLY:
<8404323f-40c3-473b-a5fd-a37e7af1cb3bn@googlegroups.com> b5d67809
@REPLYADDR Kenny McCormack
<gazelle@shell.xmission.com>
@REPLYTO 2:5075/128 Kenny McCormack
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID:
1@news.xmission.com>
@RFC-References:
<8404323f-40c3-473b-a5fd-a37e7af1cb3bn@googlegroups.com>
@TZUTC: -0000
@TID: FIDOGATE-5.12-ge4e8b94
In article <
8404323f-40c3-473b-a5fd-a37e7af1cb3bn@googlegroups.com>,
hongy...@gmail.com <
hongyi.zhao@gmail.com> wrote:
>I want to split a hex string into bytes and compute their xor, as shown below:
>
>werner@X10DAi:~$ data=$( sed `s/\\(..\\)/\\1 /g` <<<
>23230DFE4C5336413245313636504135303333333401000A130A1814300A01010101 | sed -e
>`s/[ ]*$//` )
>werner@X10DAi:~$ IFS=` ` read -ra ADDR <<< "$data"; xor=0; for i
in "${ADDR[@]}";
>do xor=$((xor ^ 0x$i)); done; printf `%x
` $xor
>ea
>
>I wonder if there is a more concise and simple method for this purpose.
$ gawk `{ x = 0; for (i=1; i<=NF; i++) x = xor(x,strtonum("0x"
$i)); print x }` FPAT=.. <<<
23230DFE4C5336413245313636504135303333333401000A130A1814300A01010101
--
People sleep peaceably in their beds at night only because rough
men stand ready to do violence on their behalf.
George Orwell
--- trn 4.0-test77 (Sep 1, 2010)
* Origin: The official candy of the new Millennium (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5075/128
@PATH: 5075/128 5020/1042 4441