1.\" Copyright (c) 1980, 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.Dd April 18, 2022 29.Dt BINTRANS 1 30.Os 31.Sh NAME 32.Nm bintrans , 33.Nm uuencode , 34.Nm uudecode , 35.Nm b64encode , 36.Nm b64decode 37.Nd encode/decode a binary file 38.Sh SYNOPSIS 39.Nm 40.Op algorithm 41.Op ... 42.Nm uuencode 43.Op Fl m 44.Op Fl r 45.Op Fl o Ar output_file 46.Op Ar file 47.Ar name 48.Nm uudecode 49.Op Fl cimprs 50.Op Ar 51.Nm uudecode 52.Op Fl i 53.Fl o Ar output_file 54.Nm b64encode 55.Op Fl r 56.Op Fl w Ar column 57.Op Fl o Ar output_file 58.Op Ar file 59.Ar name 60.Nm b64decode 61.Op Fl cimprs 62.Op Ar 63.Nm b64decode 64.Op Fl i 65.Fl o Ar output_file 66.Op Ar file 67.Nm base64 68.Op Fl d 69.Op Fl w Ar column 70.Op Ar file 71.Sh DESCRIPTION 72The 73.Nm uuencode 74and 75.Nm uudecode 76utilities are used to transmit binary files over transmission mediums 77that do not support other than simple 78.Tn ASCII 79data. 80The 81.Nm b64encode 82utility is synonymous with 83.Nm uuencode 84with the 85.Fl m 86flag specified. 87The 88.Nm b64decode 89utility is synonymous with 90.Nm uudecode 91with the 92.Fl m 93flag specified. 94.Pp 95The 96.Nm base64 97utility acts as a base64 decoder when passed the 98.Fl -decode 99.Po or 100.Fl d 101.Pc 102flag and as a base64 encoder otherwise. 103As a decoder it only accepts raw base64 input 104and as an encoder it does not produce the framing lines. 105.Nm base64 106reads standard input or 107.Ar file 108if it is provided and writes to standard output. 109Options 110.Fl -wrap 111.Po or 112.Fl w 113.Pc 114and 115.Fl -ignore-garbage 116.Po or 117.Fl i 118.Pc 119are accepted for compatibility with GNU base64, 120but the latter is unimplemented and silently ignored. 121.Pp 122The 123.Nm uuencode 124utility reads 125.Ar file 126(or by default the standard input) and writes an encoded version 127to the standard output, or 128.Ar output_file 129if one has been specified. 130The encoding uses only printing 131.Tn ASCII 132characters and includes the 133mode of the file and the operand 134.Ar name 135for use by 136.Nm uudecode . 137.Pp 138The 139.Nm uudecode 140utility transforms 141.Em uuencoded 142files (or by default, the standard input) into the original form. 143The resulting file is named either 144.Ar name 145or (depending on options passed to 146.Nm uudecode ) 147.Ar output_file 148and will have the mode of the original file except that setuid 149and execute bits are not retained. 150The 151.Nm uudecode 152utility ignores any leading and trailing lines. 153.Pp 154The following options are available for 155.Nm uuencode : 156.Bl -tag -width ident 157.It Fl m 158Use the Base64 method of encoding, rather than the traditional 159.Nm uuencode 160algorithm. 161.It Fl r 162Produce raw output by excluding the initial and final framing lines. 163.It Fl o Ar output_file 164Output to 165.Ar output_file 166instead of standard output. 167.El 168.Pp 169The following options are available for 170.Nm uudecode : 171.Bl -tag -width ident 172.It Fl c 173Decode more than one uuencoded file from 174.Ar file 175if possible. 176.It Fl i 177Do not overwrite files. 178.It Fl m 179When used with the 180.Fl r 181flag, decode Base64 input instead of traditional 182.Nm uuencode 183input. 184Without 185.Fl r 186it has no effect. 187.It Fl o Ar output_file 188Output to 189.Ar output_file 190instead of any pathname contained in the input data. 191.It Fl p 192Decode 193.Ar file 194and write output to standard output. 195.It Fl r 196Decode raw (or broken) input, which is missing the initial and 197possibly the final framing lines. 198The input is assumed to be in the traditional 199.Nm uuencode 200encoding, but if the 201.Fl m 202flag is used, or if the utility is invoked as 203.Nm b64decode , 204then the input is assumed to be in Base64 format. 205.It Fl s 206Do not strip output pathname to base filename. 207By default 208.Nm uudecode 209deletes any prefix ending with the last slash '/' for security 210reasons. 211.El 212.Pp 213Additionally, 214.Nm b64encode 215accepts the following option: 216.Bl -tag -width ident 217.It Fl w Ar column 218Wrap encoded output after 219.Ar column . 220.El 221.Pp 222.Nm 223is a generic utility that can run 224any of the aforementioned encoders and decoders. 225It can also run algorithms that are not available 226through a dedicated program: 227.Pp 228.Nm qp 229is a quoted-printable converter 230and accepts the following options: 231.Bl -tag -width ident 232.It Fl u 233Decode. 234.It Fl o Ar output_file 235Output to 236.Ar output_file 237instead of standard output. 238.Sh EXAMPLES 239The following example packages up a source tree, compresses it, 240uuencodes it and mails it to a user on another system. 241When 242.Nm uudecode 243is run on the target system, the file ``src_tree.tar.Z'' will be 244created which may then be uncompressed and extracted into the original 245tree. 246.Pp 247.Bd -literal -offset indent -compact 248tar cf \- src_tree \&| compress \&| 249uuencode src_tree.tar.Z \&| mail user@example.com 250.Ed 251.Pp 252The following example unpacks all uuencoded 253files from your mailbox into your current working directory. 254.Pp 255.Bd -literal -offset indent -compact 256uudecode -c < $MAIL 257.Ed 258.Pp 259The following example extracts a compressed tar 260archive from your mailbox 261.Pp 262.Bd -literal -offset indent -compact 263uudecode -o /dev/stdout < $MAIL | zcat | tar xfv - 264.Ed 265.Sh SEE ALSO 266.Xr basename 1 , 267.Xr compress 1 , 268.Xr mail 1 , 269.Xr uucp 1 Pq Pa ports/net/freebsd-uucp , 270.Xr uuencode 5 271.Sh HISTORY 272The 273.Nm uudecode 274and 275.Nm uuencode 276utilities appeared in 277.Bx 4.0 . 278.Sh BUGS 279Files encoded using the traditional algorithm are expanded by 35% (3 280bytes become 4 plus control information). 281