Skip to content

Instantly share code, notes, and snippets.

@tirzasrwn
Last active September 8, 2022 03:12
Show Gist options
  • Save tirzasrwn/be6e0d4a50338b34c08488dd4e2f9562 to your computer and use it in GitHub Desktop.
Save tirzasrwn/be6e0d4a50338b34c08488dd4e2f9562 to your computer and use it in GitHub Desktop.
File to ASCII in Linux

About

Convert file to ASCII. Some transfer protocol only support ASCII. We can still use it by converting our file into ASCII.

Tools

  • uuencode
  • uudecode
  • tar
  • gzip
  • gunzip

Step

  • Let's say that we have movie.mp4 file.
  • Create arcive using tar and gzip
tar cfv mymovie.tar movie.mp4
gzip mymovie.tar
  • Convert mymovie.tar.gz into ASCII
uuencode  mymovie.tar.gz mymovie.tar.gz > mymovie.tar.uu
# You need to repeat file name twice!
  • You will find mymovie.tar.gz.uu content to be like this
begin 664 mymovie.tar.gz
M4$L#!!0`"``(`(!F(54````````````````<`!``26YF;W1A:6YM96YT7U-L
M:61E<U]6,R`Q+FIP9U58#``!/1!C<#H08_4!%`"LNW54'%VS/CI8D`27)`3W
MP=W=!W>")H3@#,&#AQ#\10<&=V:`08,,3@B2X.Z#!O<0-/@EGYSS?N?\[F^M
MN];MZ7]VU73OVM6UGWKVKN[[V?L5`)&:,D@9@(:&!DAY^`'NYP$*``QT]#_G
MPX'Y<&+A8&%A8F+A86,_PGF"]^3)8[S'C_$)2(CP"8@)'C\FHB`B)B4C)R=_
  • Now you can send it via email or MQTT or others protocol that support text(ASCII).

  • So you save the message in a file, complete with headers. Let's say you call this message-file.

uudecode message-file
gunzip mymovie.tar.gz
tar xfv mymovie.tar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment