Nп/п : 28 из 100
 От   : marrgol                             2:5075/128        03 сен 23 13:48:21
 К    : Hongy                                                 03 сен 23 14:51:01
 Тема : Re: Split a hex string into bytes and compute the xor of them.
----------------------------------------------------------------------------------
                                                                                 
@MSGID: 1@dont-email.me> 9eeace3a
@REPLY:
<8404323f-40c3-473b-a5fd-a37e7af1cb3bn@googlegroups.com> b5d67809
@REPLYADDR marrgol <marrgol@address.invalid>
@REPLYTO 2:5075/128 marrgol
@CHRS: CP866 2
@RFC: 1 0
@RFC-Message-ID: 1@dont-email.me>
@RFC-References:
<8404323f-40c3-473b-a5fd-a37e7af1cb3bn@googlegroups.com>
@TZUTC: 0200
@PID: Mozilla/5.0 (rv:102.0) Gecko/20100101,
Thunderbird/102.14.0
@TID: FIDOGATE-5.12-ge4e8b94
On 2023-09-03 at 08:26 hongy...@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.

E.g.:

DATA=23230DFE4C5336413245313636504135303333333401000A130A1814300A01010101
XOR=0
while read -N2 BYTE; do ((XOR^=0x$BYTE)) ; done < <(echo $DATA)
printf `%02X
` $XOR


--- Mozilla/5.0 (rv:102.0) Gecko/20100101, Thunderbird/102.14.0
 * Origin: A noiseless patient Spider (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



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх