how to change it in to hex?

P

Pen Ttt

ni my console,hexdump -C /home/pt/kc|less,what i get is :

00000000 00 00 00 00 56 b8 32 01 06 13 00 00 00 00 00 00
00000010 00 00 00 00 00 00 1f ab ca 48 00 00 00 00 00 00

irb(main):011:0> IO.read('/home/pt/kc', 8, 0x00)
=> "\000\000\000\000V\2702\001"

how to make "\000\000\000\000V\2702\001" become 00 00 00 00 56 b8 32
01?
 
R

Robert Klemme

ni my console,hexdump -C /home/pt/kc|less,what i get is :

00000000 =A000 00 00 00 56 b8 32 01 =A006 13 00 00 00 00 00 00
00000010 =A000 00 00 00 00 00 1f ab =A0ca 48 00 00 00 00 00 00

irb(main):011:0> IO.read('/home/pt/kc', 8, 0x00)
=3D> "\000\000\000\000V\2702\001"

how to make =A0 "\000\000\000\000V\2702\001" =A0become =A000 00 00 00 56 = b8 32
01?

ri String#unpack

irb(main):006:0> s.unpack('H*').first.scan(/../).join ' '
=3D> "00 00 00 00 56 b8 32 01"

Cheers

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
 
A

Ammar Ali

ni my console,hexdump -C /home/pt/kc|less,what i get is :

00000000 =C2=A000 00 00 00 56 b8 32 01 =C2=A006 13 00 00 00 00 00 00
00000010 =C2=A000 00 00 00 00 00 1f ab =C2=A0ca 48 00 00 00 00 00 00

irb(main):011:0> IO.read('/home/pt/kc', 8, 0x00)
=3D> "\000\000\000\000V\2702\001"

how to make =C2=A0 "\000\000\000\000V\2702\001" =C2=A0become =C2=A000 00 = 00 00 56 b8 32
01?

One way is to use String#unpack to get the individual bytes from the
data string, (C* for a sequence of unsigned chars), then use Array#map
to convert the values to hex, finally to format with spaces between
the octets, use Array#join.

Regards,
Ammar
 
P

Pen Ttt

here is a part of stock data in china,i get it with command:
hexdump -C /home/pt/day|less
there are shanghai stock such as:
SH000001,SH000002,SH000003,SH000004,SH000005
i can get it
IO.read('/home/pt/day',8,0x14).unpack('A*')
=> ["SH000001"]
other fields are date,open,high,low,close,vol,turnover,
every stock have 64 bytes,maybe ff ff ff ff means the begining of
data,
would you mind to tell me how to crack the stock data file?


00000000 8c 19 fc 33 66 02 00 00 bb 05 00 00 00 00 00 00
|...3f...........|
00000010 ff ff ff ff 53 48 30 30 30 30 30 31 00 00 00 00
|....SH000001....|
00000020 9a c8 c3 a5 c9 cf d6 a4 d6 b8 ca fd 00 00 00 00
|................|
00000030 00 ee 0f 4d 71 99 32 45 b8 c2 35 45 14 ea 31 45
|...Mq.2E..5E..1E|
00000040 ec 81 35 45 f9 2b f1 4c de 55 01 52 ec 02 8c 00
|..5E.+.L.U.R....|
00000050 ff ff ff ff 53 48 30 30 30 30 30 32 00 ea 31 45
|....SH000002..1E|
00000060 9a c8 c3 a5 a3 c1 b9 c9 d6 b8 ca fd 00 02 8c 00
|................|
00000070 80 ca fe 4c 14 c6 3b 45 ae 8b 3c 45 52 24 3a 45
|...L..;E..<ER$:E|
00000080 9a 71 3a 45 33 55 bc 4c c8 81 cf 51 38 01 33 02
|.q:E3U.L...Q8.3.|
00000090 ff ff ff ff 53 48 30 30 30 30 30 33 00 24 3a 45
|....SH000003.$:E|
000000a0 9a c8 c3 a5 a3 c2 b9 c9 d6 b8 ca fd 00 01 33 02
|..............3.|
000000b0 80 ca fe 4c 8f c2 95 43 66 06 97 43 5c 8f 95 43
|...L...Cf..C\..C|
000000c0 00 00 96 43 80 7e ec 48 0e 39 ca 4d 38 01 33 02
|...C.~.H.9.M8.3.|
000000d0 ff ff ff ff 53 48 30 30 30 30 30 34 00 8f 95 43
|....SH000004...C|
000000e0 9a c8 c3 a5 b9 a4 d2 b5 d6 b8 ca fd 00 01 33 02
|..............3.|
000000f0 80 ca fe 4c 66 5a 1e 45 48 69 1f 45 33 5f 1d 45
|...LfZ.EHi.E3_.E|
00000100 71 9d 1d 45 a9 17 40 4c 16 21 89 51 38 01 33 02
|q..E..@L.!.Q8.3.|
00000110 ff ff ff ff 53 48 30 30 30 30 30 35 00 5f 1d 45
|....SH000005._.E|
00000120 9a c8 c3 a5 c9 cc d2 b5 d6 b8 ca fd 00 01 33 02
|..............3.|
00000130 80 ca fe 4c c3 4f 80 45 5c 07 81 45 f6 90 7f 45
|...L.O.E\..E...E|
00000140 33 1d 80 45 4c 20 16 4a 53 ff 56 4f 38 01 33 02 |3..EL
JS.VO8.3.|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top