2018-11-14 19:15:14 +00:00
|
|
|
---
|
|
|
|
layout: page
|
|
|
|
category-page: intermediate
|
2018-11-16 12:47:48 +00:00
|
|
|
category-title: Intermediate commands
|
2018-11-14 19:15:14 +00:00
|
|
|
tags: base64 representation
|
|
|
|
author: Gianmarco De Vita
|
2018-11-16 19:47:01 +00:00
|
|
|
title: base64
|
2018-11-18 20:38:56 +00:00
|
|
|
previous-page: pages/cmd/interm/apropos.html
|
|
|
|
next-page: pages/cmd/interm/basename.html
|
2018-11-14 19:15:14 +00:00
|
|
|
---
|
2018-11-16 19:47:01 +00:00
|
|
|
|
2018-11-14 21:15:38 +00:00
|
|
|
<i>Base64</i> is an encoding system that allows the translation of binary
|
|
|
|
data into ASCII text strings, basing upon 64 different ASCII characters.<br>
|
2018-11-14 19:15:14 +00:00
|
|
|
Each <i>Base64</i> digit represents exactly 6 bits of data so, for example,
|
2018-11-14 21:15:38 +00:00
|
|
|
six bytes (a total of 48 bits) can be represented by eight <i>Base64</i> digits.
|
2018-11-14 19:15:14 +00:00
|
|
|
|
2018-11-14 21:15:38 +00:00
|
|
|
By writing the command <code>base64</code> you can encode and decode Base64 data.
|
|
|
|
The command follows the structure:
|
2018-11-14 19:15:14 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-14 21:15:38 +00:00
|
|
|
base64 [flag] [-i input item] [-o output item]
|
2018-11-14 19:15:14 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
<h3>Defining input and output files</h3>
|
2018-11-14 21:15:38 +00:00
|
|
|
In this case, flag such as <code>-i</code> and <code>-o</code> are fundamental
|
|
|
|
to define respectevely from which file take the stream and into which to store
|
|
|
|
the result. Naturally, the path and the name of the files must be specified.
|
2018-11-14 19:15:14 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-14 21:15:38 +00:00
|
|
|
base64 -i path/input.file -o path/output.file
|
2018-11-14 19:15:14 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
<h3>Insert line breaks</h3>
|
2018-11-14 21:15:38 +00:00
|
|
|
Using the <code>-b</code> (which stands for <i>break</i>) flag followed by a
|
|
|
|
number, line breaks are added every specified "number" characters.
|
2018-11-14 19:15:14 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-14 21:15:38 +00:00
|
|
|
base64 -b number path/input.file path/output.file
|
2018-11-14 19:15:14 +00:00
|
|
|
</pre>
|
|
|
|
|
2018-11-18 20:58:49 +00:00
|
|
|
By leaving the number field empty, an unbroken stream will be generated.
|
2018-11-14 19:15:14 +00:00
|
|
|
|
|
|
|
<h3>Decode Base64</h3>
|
2018-11-14 21:15:38 +00:00
|
|
|
Using the <code>-D</code> flag (which stands for decode), you obtain as
|
|
|
|
output the input message decoded into binary data.
|
2018-11-14 19:15:14 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-14 21:15:38 +00:00
|
|
|
base64 -D [-i input item] [-o output item]
|
2018-11-14 19:15:14 +00:00
|
|
|
</pre>
|
|
|
|
|
|
|
|
<h3>Summarize the tools</h3>
|
2018-11-14 21:15:38 +00:00
|
|
|
Using the <code>-h</code> (which stands for <i>help</i>) a short paragraph
|
|
|
|
in which are listed the flags with the respective paragraph will be displayed.
|
2018-11-14 19:15:14 +00:00
|
|
|
|
|
|
|
<pre>
|
2018-11-14 21:15:38 +00:00
|
|
|
base64 -h
|
2018-11-14 19:15:14 +00:00
|
|
|
</pre>
|