btoa
btoa
(tool, messaging, algorithm, file format)btoa is a uuencode or base 64 equivalent which addressessome of the problems with the uuencode standard but not asmany as the base 64 standard. It avoids problems that somehosts have with spaces (e.g. conversion of groups of spacesto tabs) by not including them in its character set, but maystill have problems on non-ASCII systems (e.g. EBCDIC).
btoa is primarily used to transfer binary files betweensystems across connections which are not eight-bit clean,e.g. electronic mail.
btoa takes adjacent sets of four binary octets and encodesthem as five ASCII octets using ASCII characters '!' throughto 'u'. Special characters are also used: 'x' marks thebeginning or end of the archive; 'z' marks four consecutivezeros and 'y' (version 5.2) four consecutive spaces.
Each group of four octets is processed as a 32-bit integer.Call this 'I'. Let 'D' = 85^4. Divide I by D. Call thisresult 'R'. Make I = I - (R * D) to avoid overflow on thenext step. Repeat, for values of D = 85^3, 85^2, 85 and 1.At each step, to convert R to the output character add decimal33 (output octet = R + ASCII value for '!'). Five outputoctets are produced.
btoa provides some integrity checking in the form of a linechecksum, and facilities for patching corrupted downloads.
The algorithm used by btoa is more efficient than uuencodeor base 64. ASCII files are encoded to about 120% the size oftheir binary sources. This compares with 135% for uuencode orbase 64.
C source.(version 5.2 - ~1994).
Pre-compiled MS-DOS versions are also available.