Base32 decoding binary file to ascii


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Base32 decoding binary file to ascii
# 1  
Old 09-14-2015
Base32 decoding binary file to ascii

I need to convert a binary file which in encoded using base32 encoding technique and convert that into readible ASCII so that i can load the same in DB.

is there any command to do the same.

sample from the binary file lools like :

Code:
^P^A3yÃ^@(^A^@z^S<90>^@z^Yl^@^@^@^D^@^G(²<8f>'<94>^@^@^@^@^G^@^@^@^@^@^@^@^C^@^@^@^C^@^@^@^@^G<85><81>p^@^A^@^@^@1AAA                                    ^@GAAK                                    ^@A^@^@^@^@^@^@^G(²<8f>'<95><90>^@^

ascii file looks like (tab seperated fixed length):

Code:
016 20150722 0040 001 08000400 08001900 0000004 2015072208000000 0000007


help much appreciated.

I tried using python base64 , but in vain .

---------- Post updated at 03:44 PM ---------- Previous update was at 03:39 PM ----------

Quote:
Originally Posted by krk
I need to convert a binary file which in encoded using base32 encoding technique and convert that into readible ASCII so that i can load the same in DB.

is there any command to do the same.

sample from the binary file lools like :

^P^A3yÃ^@(^A^@z^S<90>^@z^Yl^@^@^@^D^@^G(²<8f>'<94>^@^@^@^@^G^@^@^@^@^@^@^@^C^@^@^@^C^@^@^@^@^G<85>< 81>p^@^A^@^@^@1AAA ^@GAAK ^@A^@^@^@^@^@^@^G(²<8f>'<95><90>^@^

ascii file looks like (tab seperated fixed length):

Code:
016 20150722 0040 001 08000400 08001900 0000004 2015072208000000 0000007


help much appreciated.

I tried using python base64 , but in vain .

Last edited by rbatte1; 09-23-2015 at 01:12 PM.. Reason: Added CODE tags for data
# 2  
Old 09-14-2015
That doesn't look like a base32 coded file (which shouldn't have any control chars in it.
# 3  
Old 09-14-2015
the o/p above is from VI editor .
when i do head -2 <binary_filename> , i get data in below format.

Code:
(²(ã(042393553                               00442894484608                                                                  0              0   0     (² nOUTPEAKI_000044_A011100        I_000044_A01L    INTL BT   VEUR##,0  0    ?a4êJ0   @??QÛʧ]@??QÛʧ]              0@?@?@?@?(CAS@?@?0           0           3yÂ({{~Ø(²'½½
w1AAA                                    GAAH                                    (²((²((²)Ø016276111                               0031402087389                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01V    INTL BT   VEUR##,0  0    ?l1&éy0   @i@? Õù9@i@? Õù9              0@i@@i@@i@@i@(CAS@i@@i@0           0           3yÂ(zé<{*(²'ÌÌ
x1AAA                                    GAAA                                    (²(k<(²(k<(²)*035402510                               00390245518487                                                                  0              0   0     (² nOUTPEAKI_000039_A011100        I_000039_A01A    INTL BT   VEUR##,0  0    ?_!-w1Å0   @o ?(¡ß¹8o ?(¡ß¹8o @o @o @o (CAS@o @o 0           0           3yÂ({ª4{¬(²'ìì
y1AAA                                    GAAK                                    (²),4(²),4(²).051300440                               0031623134206                                                                   0              0   0     (² nOUTPEAKI_000031_M031100        I_000031_M03K    INTL BT   VEUR##,0  0    ?@N¤¨ÁU0   @?^ÍJ¡!@?^ÍJ¡!              0@@@@(CAS@@0           0           3yÂ(|0|d(²'QQ
z1AAA                                    BA0Z                                    (²)0(²)0(²*d081423716                               0022996724865                                                                   0              0   0     (² nOUTPEAKI_000229_M061300        I_000229_M06N    INTL BT   VEUR##,0  0    ?¾ÿ$tT0   @c*?ÓþÚf@c*?ÓþÚf              0@c*@c*@c*@c*(CAS@c*@c*0           0           3yÂ(|
X|°((²']]                                                                                                                                     ¸ºÇ              0@@@@(CAS@@0           0           3yÂ(|1AAA                                    GAAA                                    (²)ç´(²)ç´(²*033170734                               0031297519937                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01A    INTL BT   VEUR##,0  0    ?l1&éy0   @O?m§°³d@O?m§°³d              0@O@O@O@O(CAS@O@O0           0           3yÂ({X,|Ú(²'
}1AAA                                    GAAN                                    (²(Ú,(²(Ú,(²*\010415006                               002302637583                                                                    0              0   0     (² nOUTPEAKI_000230_A011100        I_000230_A01N    INTL BT   VEUR##,0  0    ?¶Ë}At?@h?ëË}At?              0@h@h@h@h(CAS@h@h0           0           3yÂ(|ÓÜ}!ü(²'ÔÔ
~1AAA                                    GAAH                                    (²*UÜ(²*UÜ(²*£ü011645442                               0031495591454                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01H    INTL BT   VEUR##,0  0    ?l1&éy0   @^?|1&éy@^?|1&éy              0@^@^@^@^(CAS@^@^0           0           3yÂ(}}'(²'ßß
1AAA                                    GAAG                                    (²*(²*(²*©052219999                               0031318527373                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01G    INTL BT   VEUR##,0  0    ?l1&éy0   @2?Q4êJ@2?Q4êJ              0@2@2@2@2(CAS@2@20           0           3yÂ(})Ì},ì(²'íí
1AAA                                    GAAK                                    (²*«Ì(²*«Ì(²*®ì050710720                               0031756476611                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01K    INTL BT   VEUR##,0  0    ?l1&éy0   @ ?>ÍJ¡!@ ?>ÍJ¡!              0@ @ @ @ (CAS@ @ 0           0           3yÂ(}PÜ}d(²';;
1AAA                                    GAAK                                    (²*ÒÜ(²*ÒÜ(²+d056644042                               0031492531919                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01K    INTL BT   VEUR##,0  0    ?l1&éy0   @X?wmÚÎî=@X?wmÚÎî=              0@X@X@X@X(CAS@X@X0           0           3yÂ(}8}Àø(²'WW
1AAA                                    GAAA                                    (²+8(²+8(²+Bø035440375                               0031786810780                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01A    INTL BT   VEUR##,0  0    ?l1&éy0   @R?q4êJ@R?q4êJ              0@R@R@R@R(CAS@R@R0           0           3y¬}Âì(²'^^
1AAA                                    GAAA                                    (²*¬(²*¬(²+Dì036662000                               0031653549112                                                                   0              0   0     (² nOUTPEAKI_000031_M031100        I_000031_M03A    INTL BT   VEUR##,0  0    ?@N¤¨ÁU0   @p?µ-#N¹¡w@p?µ-#N¹¡w              0@p@p@p@p(CAS@p@p0           0           3yÂ(~6ð~BD(²'ºº

1AAA                                    GAAA                                    (²+¸ð(²+¸ð(²+ÄD038865390                               0031416274732                                                                   0              0   0     (² nOUTPEAKI_000031_A011100        I_000031_A01A    INTL BT   VEUR##,0  0    ?l1&éy0   @=?[°_®¼@@=?[°_®¼@              0@=@=@=@=(CAS@=@=0           0           3yÂ(~¨~B¨(²'¼¼

1AAA                                    GAAA                                    (²+¨(²+¨(²+Ĩ032255999                               00912223691100                                                                  0              0   0     (² nOUTPEAKI_000091_C031100        I_000091_C03A    INTL BT   VEUR##,0  0    ?t¼j~ùÛ0   @V?Tów[@V?Tów[              0@V@V@V@V(CAS@V@V0           0


Last edited by Corona688; 09-14-2015 at 12:10 PM..
# 4  
Old 09-14-2015
At the moment the lines you have given us are meaningless.

Please do a hexdump of part of the REAL BINARY file and the expected ASCII readout.

EG:-
Code:
hexdump -C /full/path/to/binary.file

(An example.)
Code:
AMIGA:barrywalker~/Desktop/Code/Shell> hexdump -C ~/Desktop/Code/Shell/binary2
00000000  00 00 00 0a 0a 0a 09 09  09 20 20 20 00 0a 09 5c  |.........   ...\|
00000010  20 0a 00 5c 20 09 20 20  20 0a 0a 0a              | ..\ .   ...|
0000001c

# 5  
Old 09-14-2015
hexdump o/p is as follows

Code:
9b0  00 00 40 3d 00 00 00 00  00 00 30 20 20 20 20 20  |..@=......0     |
000039c0  20 20 20 20 20 20 00 30  20 20 20 20 20 20 20 20  |      .0        |
000039d0  20 20 20 00 00 00 10 01  33 79 c2 00 28 01 00 7e  |   .....3y..(..~|
000039e0  10 a8 00 7e 42 a8 00 00  00 04 00 07 28 b2 8f 27  |...~B.......(..'|
000039f0  94 00 00 00 00 07 00 00  00 00 00 00 02 bc 00 00  |................|
00003a00  02 bc 00 00 00 00 07 85  81 85 00 01 00 00 00 31  |...............1|
00003a10  41 41 41 20 20 20 20 20  20 20 20 20 20 20 20 20  |AAA             |
00003a20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003a30  20 20 20 20 20 20 20 00  47 41 41 41 20 20 20 20  |       .GAAA    |
00003a40  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00003a60  00 01 00 00 00 00 00 00  07 28 b2 8f 2b 92 a8 00  |.........(..+...|
00003a70  07 28 b2 8f 2b 92 a8 00  07 28 b2 8f 2b c4 a8 00  |.(..+....(..+...|
00003a80  02 00 30 33 32 32 35 35  39 39 39 20 20 20 20 20  |..032255999     |
00003a90  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003aa0  20 20 20 20 20 20 20 20  20 20 00 00 30 30 39 31  |          ..0091|
00003ab0  32 32 32 33 36 39 31 31  30 30 20 20 20 20 20 20  |2223691100      |
00003ac0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003ad0  20 20 20 20 00 00 20 20  20 20 20 20 20 20 20 20  |    ..          |
00003ae0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00003af0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 00 00  |              ..|
00003b00  01 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00003b10  00 00 00 00 00 00 00 00  00 30 20 20 20 20 20 20  |.........0      |
00003b20  20 20 20 20 20 20 20 20  00 00 00 00 01 00 00 00  |        ........|


Last edited by Corona688; 09-14-2015 at 12:09 PM..
# 6  
Old 09-14-2015
The effort to use code tags is appreciated, however you are using the wrong button, to use code tags please use the code button, the one that says code on it, Image
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 09-14-2015
Hi krk...

Why did you cut and paste badly almost 14KB into the file?

From that I still cannot associate the string of numbers in your post #1.

If possible do a hexdump of the first 1KB, (or maybe 2KB), of the file so I can find possible starts and ends of any __lines__...

As it stands I can't see any relationship with the numerical string(s) and the part you have shown...

EDIT:
You could look at man strings , as it extracts ascii strings from binary files...

Last edited by wisecracker; 09-14-2015 at 03:27 PM.. Reason: See above...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File conversion from Binary to ASCII though UNIX command

Hi All , I have a mainframe file which contains the data in EBCDIC format.I have downloaded this file from mainframe to windows in binary format(unreadable raw data).Now I want convert this file to ASCII format(readable format data) through Unix command.I have tried iconv but that is not working... (2 Replies)
Discussion started by: STCET22
2 Replies

2. Shell Programming and Scripting

Converting a binary file to ascii and vice versa?

Hi All, I have a binary file which is being exported from a Database, and i need to convert that to ASCII format. How can i achieve that? And this solution should work for any file which is given to us; means they will give different files from different tables. Thanks in advance. (8 Replies)
Discussion started by: baranisachin
8 Replies

3. Shell Programming and Scripting

Difference between ascii and binary file -

what is the diff between ascii and binary file. my understand is that.. ascii file - has only line feed - \n in it where as binary file - has both line feed and carriage return in it- \r\n is that correct. also,what is the ksh command to identify whether it is a binary or ascii... (1 Reply)
Discussion started by: billpeter3010
1 Replies

4. UNIX for Dummies Questions & Answers

Ascii or Binary?

Hello all, I am working with ftp servers in unix, and always I have to get and put files but I don't know exactly if I have to get or put them as an ascii or binary. Some files that I use are: .txt, .sav, .fmb, .pct, .sh, .ksh, .dat, .log. Somebody can tell me what is the difference between... (2 Replies)
Discussion started by: Geller
2 Replies

5. Programming

Reading a binary file in text or ASCII format

Hi All, Please suggest me how to read a binary file in text or ASCII format. thanks Nagendra (3 Replies)
Discussion started by: Nagendra
3 Replies

6. Shell Programming and Scripting

binary to ascii

Hi, Is there a way to convert the binary file to ascii . the binary file is pipe delimited. from source the file(pipe delimited) is ftped to mainframe and from mainframe it is ftped to the unix box using binary format. Is there a way to change it back to ascii and view it? Thanks! (3 Replies)
Discussion started by: dnat
3 Replies

7. Shell Programming and Scripting

how to check the file data type(ascii or binary)

hi i am receiving a file from one system , i have to verify the format of the file data i.e whether the data is in acii format or binary format, please help thanks in advance satya (1 Reply)
Discussion started by: Satyak
1 Replies

8. Shell Programming and Scripting

Binary or ascii file

I want to verify the file is Binary or ascii file and accordingly I want to switch the program with ret code ie 0 or success and 1 for failure Can any one help me is this a correct syntex...i am getting error #!/bin/ksh $file filename if echo "ascii fie Found" else echo " binary... (6 Replies)
Discussion started by: u263066
6 Replies

9. Solaris

problem when decoding a binary file

I tried to decode a binary script using the command 'uudecode'. but it is giving error as 'No begining line'. 'uudecode -o <outfile name> <binary file>' Please help me in resolving this. (4 Replies)
Discussion started by: vamshikrishnab
4 Replies

10. Shell Programming and Scripting

ftp - determine ascii or binary file

Hello, How to i determine via ftp commandline if files on ftp server is ascii or binary files. Like every other comon windows ftp program does it automatically. regards Thomas (5 Replies)
Discussion started by: congo
5 Replies
Login or Register to Ask a Question