Base64 decode data: Difference between revisions

From Rosetta Code
Content added Content deleted
(added RPL)
 
(36 intermediate revisions by 23 users not shown)
Line 6: Line 6:


When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously with incorrect padding in the output you can not decode correctly to the original file again.
When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously with incorrect padding in the output you can not decode correctly to the original file again.

=={{header|Action!}}==
<syntaxhighlight lang="action!">BYTE FUNC FindIndex(BYTE b)
IF b>='A AND b<='Z THEN
RETURN (b-'A)
ELSEIF b>='a AND b<='z THEN
RETURN (b-'a+26)
ELSEIF b>='0 AND b<='9 THEN
RETURN (b-'0+52)
ELSEIF b='+ THEN
RETURN (62)
ELSEIF b='/ THEN
RETURN (63)
FI
RETURN (-1)

PROC PrintChar(CHAR c)
IF c=10 THEN
PutE()
ELSE
Put(c)
FI
RETURN

PROC Decode(CHAR ARRAY s)
BYTE i,b1,b2,b3,b4,i1,i2,i3,i4
CHAR c

IF s(0) MOD 4#0 THEN
PrintE("Invalid length of string!!!")
Break()
FI

i=1
WHILE i<=s(0)
DO
b1=s(i) i==+1
b2=s(i) i==+1
b3=s(i) i==+1
b4=s(i) i==+1

i1=FindIndex(b1)
i2=FindIndex(b2)

c=i1 LSH 2
c==%i2 RSH 4
PrintChar(c)

IF b3#'= THEN
i3=FindIndex(b3)
c=(i2&$0F) LSH 4
c==%i3 RSH 2
PrintChar(c)

IF b4#'= THEN
i4=FindIndex(b4)
c=(i3&$03) LSH 6
c==%i4
PrintChar(c)
FI
FI
OD
RETURN

PROC Test(CHAR ARRAY s)
PrintE("Encoded:")
PrintE(s)
PutE()
PrintE("Decoded:")
Decode(s)
PutE()
RETURN

PROC Main()
Test("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo")
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Base64_decode_data.png Screenshot from Atari 8-bit computer]
<pre>
Encoded:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo

Decoded:
To err is human, but to really foul things up you need a computer.
--Paul R.Ehrlich
</pre>


=={{header|Ada}}==
=={{header|Ada}}==
{{libheader|AWS}}
{{libheader|AWS}}
<lang Ada>with Ada.Text_IO;
<syntaxhighlight lang="ada">with Ada.Text_IO;


with AWS.Translator;
with AWS.Translator;
Line 22: Line 108:
Ada.Text_IO.New_Line;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line (Result);
Ada.Text_IO.Put_Line (Result);
end Decode_AWS;</lang>
end Decode_AWS;</syntaxhighlight>


{{out}}
{{out}}
Line 32: Line 118:
=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>text: "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
<syntaxhighlight lang="rebol">text: "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="


print decode text</lang>
print decode text</syntaxhighlight>


{{out}}
{{out}}
Line 40: Line 126:
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich</pre>
-- Paul R. Ehrlich</pre>

=={{header|BaCon}}==
Using the result from the [[Base64 encode data]] task as requested, but the result is abbreviated in the code below.
<lang bacon>data$ = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAE.......QAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="
ico$ = B64DEC$(data$)
BSAVE ico$ TO "favicon.ico" SIZE LEN(ico$)</lang>


=={{header|Bash}}==
=={{header|Bash}}==
{{trans|Bash}}
{{trans|Bash}}
<lang bash>#! /bin/bash
<syntaxhighlight lang="bash">#! /bin/bash
declare -a encodeTable=(
declare -a encodeTable=(
# + , - . / 0 1 2 3 4 5 6 7 8 9 :
# + , - . / 0 1 2 3 4 5 6 7 8 9 :
Line 103: Line 183:
fi
fi
done
done
done</lang>
done</syntaxhighlight>

=={{header|BASIC}}==
==={{header|BaCon}}===
Using the result from the [[Base64 encode data]] task as requested, but the result is abbreviated in the code below.
<syntaxhighlight lang="bacon">data$ = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAE.......QAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="
ico$ = B64DEC$(data$)
BSAVE ico$ TO "favicon.ico" SIZE LEN(ico$)</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
{{trans|C++}}
{{trans|C++}}
<lang c>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>


Line 185: Line 272:


return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
Line 192: Line 279:
--Paul R.Ehrlich</pre>
--Paul R.Ehrlich</pre>


=={{header|C#|C_sharp}}==
=={{header|C sharp|C#}}==
{{trans|Visual Basic .NET}}
{{trans|Visual Basic .NET}}
<lang csharp>using System;
<syntaxhighlight lang="csharp">using System;
using System.Text;
using System.Text;


Line 208: Line 295:
}
}
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 217: Line 304:
=={{header|C++}}==
=={{header|C++}}==
{{Works with|C++14}}
{{Works with|C++14}}
<lang cpp>#include <algorithm>
<syntaxhighlight lang="cpp">#include <algorithm>
#include <iostream>
#include <iostream>
#include <string>
#include <string>
Line 333: Line 420:


return 0;
return 0;
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
Line 349: Line 436:
=={{header|Clojure}}==
=={{header|Clojure}}==


<lang clojure>(defn decode [str]
<syntaxhighlight lang="clojure">(defn decode [str]
(String. (.decode (java.util.Base64/getDecoder) str)))
(String. (.decode (java.util.Base64/getDecoder) str)))


(decode "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")
(decode "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 363: Line 450:
Similar to the [http://rosettacode.org/wiki/Base64_encode_data#Common_Lisp BASE64 encoding task] I am using the [http://quickdocs.org/cl-base64/ cl-base64] library.
Similar to the [http://rosettacode.org/wiki/Base64_encode_data#Common_Lisp BASE64 encoding task] I am using the [http://quickdocs.org/cl-base64/ cl-base64] library.


<lang lisp>(eval-when (:load-toplevel :compile-toplevel :execute)
<syntaxhighlight lang="lisp">(eval-when (:load-toplevel :compile-toplevel :execute)
(ql:quickload "cl-base64"))
(ql:quickload "cl-base64"))


Line 385: Line 472:
(len (length array)))
(len (length array)))
(write-sequence array stream)
(write-sequence array stream)
(format t "Wrote ~D bytes in file ~A~%" len file))))</lang>
(format t "Wrote ~D bytes in file ~A~%" len file))))</syntaxhighlight>
{{out}}
{{out}}


Line 391: Line 478:


=={{header|Crystal}}==
=={{header|Crystal}}==
<lang ruby>require "base64"
<syntaxhighlight lang="ruby">require "base64"


encoded_string = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
encoded_string = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="


decoded_string = Base64.decode_string(encoded_string)
decoded_string = Base64.decode_string(encoded_string)
puts decoded_string</lang>
puts decoded_string</syntaxhighlight>


{{out}}
{{out}}
Line 405: Line 492:
=={{header|D}}==
=={{header|D}}==
{{trans|Raku}}
{{trans|Raku}}
<lang d>import std.base64;
<syntaxhighlight lang="d">import std.base64;
import std.stdio;
import std.stdio;


Line 415: Line 502:
auto decoded = cast(char[])Base64.decode(data);
auto decoded = cast(char[])Base64.decode(data);
writeln(decoded);
writeln(decoded);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 421: Line 508:
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich</pre>
-- Paul R. Ehrlich</pre>

=={{header|Dart}}==
<syntaxhighlight lang="dart">import 'dart:convert';

void main() {
var encoded = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
var decoded = utf8.decode(base64.decode(encoded));
print(decoded);
}</syntaxhighlight>

{{out}}
<pre>
To err is human, but to really foul things up you need a computer.
--Paul R.Ehrlich
</pre>


=={{header|Delphi}}==
=={{header|Delphi}}==
<lang delphi>program Base64Decoder;
<syntaxhighlight lang="delphi">program Base64Decoder;


{$APPTYPE CONSOLE}
{$APPTYPE CONSOLE}
Line 438: Line 540:


end.
end.
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>Source string:
<pre>Source string:
Line 446: Line 548:
-- Paul R. Ehrlich"</pre>
-- Paul R. Ehrlich"</pre>


=={{header|F#}}==
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
/**
* This implementation is encapsulated as Base64Format in the web.xtclang.org module,
* but the module is currently in flux, so the implementation is included "inline" here.
*/
module Base64 {
@Inject Console console;
void run() {
String orig = \|VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIH\
|lvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
;
Byte[] bytes = decode(orig);
String text = encode(bytes, pad=True);
assert text == orig;
console.print($"base64={text}, bytes={bytes}");
}

static Byte[] read(Iterator<Char> stream) {
Int charLen = 0;
charLen := stream.knownSize();
Byte[] byteBuf = new Byte[](charLen * 6 / 8);
Byte prevBits = 0;
Int prevCount = 0;
while (Char ch := stream.next()) {
if (Byte newBits := isBase64(ch, assertTrash=True)) {
if (prevCount == 0) {
prevBits = newBits;
prevCount = 6;
} else {
byteBuf.add((prevBits << 8-prevCount) | (newBits >> prevCount-2));
prevBits = newBits;
prevCount -= 2;
}
}
}

return byteBuf.freeze(True);
}

static void write(Byte[] value, Appender<Char> stream, Boolean pad=False, Int? lineLength=Null) {
lineLength ?:= Int.MaxValue;

Int lineOffset = 0;
Int totalChars = 0;
Byte prevByte = 0;
Int prevCount = 0; // number of leftover bits from the previous byte
Int byteOffset = 0;
Int byteLength = value.size;
while (True) {
// glue together the next six bits, which will create one character of output
Byte sixBits;
if (byteOffset >= byteLength) {
if (prevCount == 0) {
break;
}
sixBits = prevByte << 6 - prevCount;
prevCount = 0;
} else if (prevCount == 6) {
sixBits = prevByte << 6 - prevCount;
prevCount = 0;
} else {
Byte nextByte = value[byteOffset++];
sixBits = (prevByte << 6 - prevCount) | (nextByte >> 2 + prevCount);
prevByte = nextByte;
prevCount += 2;
}

if (lineOffset >= lineLength) {
stream.add('\r').add('\n');
totalChars += lineOffset;
lineOffset = 0;
}

stream.add(base64(sixBits & 0b111111));
++lineOffset;
}

if (pad) {
totalChars += lineOffset;
for (Int i = 0, Int padCount = 4 - (totalChars & 0b11) & 0b11; i < padCount; ++i) {
if (lineOffset >= lineLength) {
stream.add('\r').add('\n');
lineOffset = 0;
}

stream.add('=');
++lineOffset;
}
}
}

static String encode(Byte[] value, Boolean pad=False, Int? lineLength=Null) {
// calculate buffer size
Int byteLen = value.size;
Int charLen = (byteLen * 8 + 5) / 6;
if (pad) {
charLen += 4 - (charLen & 0b11) & 0b11;
}
if (lineLength != Null) {
charLen += ((charLen + lineLength - 1) / lineLength - 1).maxOf(0) * 2;
}

StringBuffer charBuf = new StringBuffer(charLen);
write(value, charBuf, pad, lineLength);
return charBuf.toString();
}

static Byte[] decode(String text) {
Int charLen = text.size;
Byte[] byteBuf = new Byte[](charLen * 6 / 8);
Byte prevBits = 0;
Int prevCount = 0;
for (Int offset = 0; offset < charLen; ++offset) {
if (Byte newBits := isBase64(text[offset], assertTrash=True)) {
if (prevCount == 0) {
prevBits = newBits;
prevCount = 6;
} else {
byteBuf.add((prevBits << 8-prevCount) | (newBits >> prevCount-2));
prevBits = newBits;
prevCount -= 2;
}
}
}

return byteBuf.freeze(True);
}

/**
* Translate a single Base64 character to the least significant 6 bits of a `Byte` value.
*
* @param ch the Base64 character; no pad or newlines allowed
*
* @return the value in the range `0 ..< 64`
*/
static Byte valOf(Char ch) {
return switch (ch) {
case 'A'..'Z': (ch - 'A').toUInt8();
case 'a'..'z': (ch - 'a').toUInt8() + 26;
case '0'..'9': (ch - '0').toUInt8() + 52;
case '+': 62;
case '/': 63;

case '=': assert as $"Unexpected padding character in Base64: {ch.quoted()}";
case '\r', '\n': assert as $"Unexpected newline character in Base64: {ch.quoted()}";
default: assert as $"Invalid Base64 character: {ch.quoted()}";
};
}

/**
* Translate a single Base64 character to the least significant 6 bits of a `Byte` value.
*
* @param ch the character to test if it is Base64
* @param assertTrash (optional) pass True to assert on illegal Base64 characters
*
* @return the value in the range `0 ..< 64`
*/
static conditional Byte isBase64(Char ch, Boolean assertTrash=False) {
return switch (ch) {
case 'A'..'Z': (True, (ch - 'A').toUInt8());
case 'a'..'z': (True, (ch - 'a').toUInt8() + 26);
case '0'..'9': (True, (ch - '0').toUInt8() + 52);
case '+': (True, 62);
case '/': (True, 63);

case '=': // "pad" sometimes allowed (or required) at end
case '\r', '\n': // newlines sometimes allowed (or required)
False;

default: assertTrash ? assert as $"Invalid Base64 character: {ch.quoted()}" : False;
};
}

/**
* Convert the passed byte value to a Base64 character.
*
* @param the byte value, which must be in the range `0..63`
*
* @return the Base64 character
*/
static Char base64(Byte byte) {
return switch (byte) {
case 0 ..< 26: 'A'+byte;
case 26 ..< 52: 'a'+(byte-26);
case 52 ..< 62: '0'+(byte-52);
case 62: '+';
case 63: '/';
default: assert:bounds as $"byte={byte}";
};
}
}
</syntaxhighlight>

{{out}}
<pre>
base64=VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=, bytes=0x546F206572722069732068756D616E2C2062757420746F207265616C6C7920666F756C207468696E677320757020796F75206E656564206120636F6D70757465722E0A202020202D2D205061756C20522E204568726C696368
</pre>

=={{header|F_Sharp|F#}}==
===Standard Library===
===Standard Library===
<lang fsharp>
<syntaxhighlight lang="fsharp">
open System
open System
open System.IO
open System.IO
Line 457: Line 758:


File.WriteAllBytes("favicon.ico", decoded)
File.WriteAllBytes("favicon.ico", decoded)
</syntaxhighlight>
</lang>
{{out}}
{{out}}
[https://rosettacode.org/favicon.ico Rosetta Code Icon]
[https://rosettacode.org/favicon.ico Rosetta Code Icon]


===Manual Implementation===
===Manual Implementation===
<lang fsharp>
<syntaxhighlight lang="fsharp">
open System
open System
open System.IO
open System.IO
Line 489: Line 790:


File.WriteAllBytes("favicon.ico", decoded)
File.WriteAllBytes("favicon.ico", decoded)
</syntaxhighlight>
</lang>
{{out}}
{{out}}
[https://rosettacode.org/favicon.ico Rosetta Code Icon]
[https://rosettacode.org/favicon.ico Rosetta Code Icon]


=={{header|Factor}}==
=={{header|Factor}}==
<lang factor>USING: base64 io strings ;
<syntaxhighlight lang="factor">USING: base64 io strings ;


"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
base64> >string print</lang>
base64> >string print</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 512: Line 813:
Inspired from Wikipedia. Use of a buffer.
Inspired from Wikipedia. Use of a buffer.
May be also of interest : github.com/lietho/base64-forth
May be also of interest : github.com/lietho/base64-forth
<lang forth>variable bitsbuff
<syntaxhighlight lang="forth">variable bitsbuff


: char>6bits ( c -- u )
: char>6bits ( c -- u )
Line 546: Line 847:
rot - ( addr2 n2 )
rot - ( addr2 n2 )
;
;
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 569: Line 870:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>Dim Shared As String B64
<syntaxhighlight lang="freebasic">Dim Shared As String B64
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
"abcdefghijklmnopqrstuvwxyz" & _
"abcdefghijklmnopqrstuvwxyz" & _
Line 601: Line 902:
Print msg64
Print msg64
Print: Print(Decode64(msg64))
Print: Print(Decode64(msg64))
Sleep</lang>
Sleep</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 608: Line 909:
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich
-- Paul R. Ehrlich
</pre>

=={{header|Frink}}==
This reproduces the Rosetta Code icon as specified in the [[Base64 encode data]] task.
<synta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ibm1vA
9g5x2DB29/br9Ug0phtxJj5QErHDhnB0nFDCTMET4PTsPJm8uLwSyzXpKQlNZ7LZ
m9tG6B15pKTmvn/I5QuPzbfqU7Fkf34R3+tbqSjF2FouV6pSvfZeEcatcR9S9/OL
/+ey+g38tOb/AjOBNqW00PrwAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE1LTA4LTAy
VDIwOjM5OjEwKzAwOjAw98IZEQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNS0wOC0w
MlQyMDozOToxMCswMDowMIafoa0AAABGdEVYdHNvZnR3YXJlAEltYWdlTWFnaWNr
IDYuNy44LTkgMjAxNC0wNS0xMiBRMTYgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5v
cmfchu0AAAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAGHRF
WHRUaHVtYjo6SW1hZ2U6OmhlaWdodAAxOTIPAHKFAAAAF3RFWHRUaHVtYjo6SW1h
Z2U6OldpZHRoADE5MtOsIQgAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9w
bmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTQzODU0Nzk1MNul3mEAAAAPdEVY
dFRodW1iOjpTaXplADBCQpSiPuwAAABWdEVYdFRodW1iOjpVUkkAZmlsZTovLy9t
bnRsb2cvZmF2aWNvbnMvMjAxNS0wOC0wMi8xNDBkYmM4M2RmNWY3NmQyNmIzYWNl
M2ZlYTViYzI5ZS5pY28ucG5nBect2gAAAABJRU5ErkJggg=="""

f = newJava["java.io.FileOutputStream", ["favicon.ico"]]
f.write[base64DecodeToBytes[s]]
f.close[]</syntaxhighlight>

=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSlog.incl"

local fn EncodeStringAsBase64( stringToEncode as CFStringRef ) as CFStringRef
CFStringRef encodedBase64Str = NULL
CFDataRef dataToEncode = fn StringData( stringToEncode, NSUTF8StringEncoding )
encodedBase64Str = fn DataBase64EncodedString( dataToEncode, 0 )
end fn = encodedBase64Str


local fn DecodeBase64String( base64String as CFStringRef ) as CFStringRef
CFStringRef decodedString = NULL
CFDataRef encodedData = fn DataWithBase64EncodedString( base64String, NSDataBase64DecodingIgnoreUnknownCharacters )
decodedString = fn StringWithData( encodedData, NSUTF8StringEncoding )
end fn = decodedString


CFStringRef originalString, encodedBase64String, decodedBase64String

originalString = @"This is a test string to be encoded as Base64 and then decoded."
NSLog( @"This is the original string:\n\t%@\n", originalString )

encodedBase64String = fn EncodeStringAsBase64( originalString )
NSLog( @"This is the original string encoded as Base84:\n\t%@\n", encodedBase64String )

decodedBase64String = fn DecodeBase64String( encodedBase64String )
NSLog( @"This is the Base64 string decoded:\n\t%@", decodedBase64String )

HandleEvents
</syntaxhighlight>
{{output}}
<pre>
This is the original string:
This is a test string to be encoded as Base64 and then decoded.

This is the original string encoded as Base84:
VGhpcyBpcyBhIHRlc3Qgc3RyaW5nIHRvIGJlIGVuY29kZWQgYXMgQmFzZTY0IGFuZCB0aGVuIGRlY29kZWQu

This is the Base64 string decoded:
This is a test string to be encoded as Base64 and then decoded.
</pre>
</pre>


Line 613: Line 994:
=={{header|Go}}==
=={{header|Go}}==
As images can no longer be uploaded to RC, I've encoded and decoded a string rather than the Rosetta Code icon.
As images can no longer be uploaded to RC, I've encoded and decoded a string rather than the Rosetta Code icon.
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 631: Line 1,012:
}
}
fmt.Println("\nDecoded :", string(decoded))
fmt.Println("\nDecoded :", string(decoded))
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 644: Line 1,025:
=={{header|Groovy}}==
=={{header|Groovy}}==
{{trans|Java}}
{{trans|Java}}
<lang groovy>import java.nio.charset.StandardCharsets
<syntaxhighlight lang="groovy">import java.nio.charset.StandardCharsets


class Decode {
class Decode {
Line 654: Line 1,035:
System.out.println(decodedStr)
System.out.println(decodedStr)
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
Line 661: Line 1,042:
=={{header|Haskell}}==
=={{header|Haskell}}==
Simple implementation that decodes an ASCII string.
Simple implementation that decodes an ASCII string.
<lang haskell>--Decodes Base64 to ASCII
<syntaxhighlight lang="haskell">--Decodes Base64 to ASCII
import qualified Data.Map.Strict as Map (Map, lookup, fromList)
import qualified Data.Map.Strict as Map (Map, lookup, fromList)
import Data.Maybe (fromJust, listToMaybe, mapMaybe)
import Data.Maybe (fromJust, listToMaybe, mapMaybe)
Line 700: Line 1,081:
putStrLn $
putStrLn $
byteToASCII
byteToASCII
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA=="</lang>
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA=="</syntaxhighlight>
{{Out}}
{{Out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
Line 709: Line 1,090:
or in terms of Data.ByteString.Base64:
or in terms of Data.ByteString.Base64:


<lang haskell>{-# LANGUAGE OverloadedStrings #-}
<syntaxhighlight lang="haskell">{-# LANGUAGE OverloadedStrings #-}


import qualified Data.ByteString.Base64 as Base64 (decode, encode)
import qualified Data.ByteString.Base64 as Base64 (decode, encode)
Line 722: Line 1,103:
either print B.putStrLn $
either print B.putStrLn $
Base64.decode
Base64.decode
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA=="</lang>
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA=="</syntaxhighlight>
{{Out}}
{{Out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA==
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA==
Line 732: Line 1,113:


=={{header|Haxe}}==
=={{header|Haxe}}==
<lang haxe>class Main {
<syntaxhighlight lang="haxe">class Main {
static function main() {
static function main() {
var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
Line 740: Line 1,121:
Sys.println(decoded);
Sys.println(decoded);
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich</pre>
-- Paul R. Ehrlich</pre>

=={{header|J}}==
using J's [https://github.com/jsoftware/convert_misc/blob/master/base64.ijs convert/misc/base64] script:

<syntaxhighlight lang="j"> require'convert/misc/base64'
frombase64 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich</syntaxhighlight>

Alternative implementation based on that script:

<syntaxhighlight lang="j">
BASE64=: (a.{~ ,(a.i.'Aa') +/i.26),'0123456789+/'

frombase64=: {{
pad=. _2 >. (y i. '=') - #y
pad }. a. {~ #. _8 [\ , (6#2) #: BASE64 i. y
}}
</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
<p>
Java offers the <code>Base64</code> class, which includes both the <code>Encoder</code> and <code>Decoder</code> classes.<br />
The implementation supports RFC 4648 and RFC 2045.
</p>
<p>
Similar to the encoding process, the usage is very simple, supply a <code>byte</code> array, and it will return an encoded <code>byte</code> array.
</p>
<p>
The class uses a static construct, so instead of instantiation via a constructor, you use one of the <kbd>static</kbd> methods.<br />
In this case we'll use the <code>Base64.getDecoder</code> method to acquire our instance.
</p>
<syntaxhighlight lang="java">
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Base64;
</syntaxhighlight>
<syntaxhighlight lang="java">
void decodeToFile(String path, byte[] bytes) throws IOException {
try (FileOutputStream stream = new FileOutputStream(path)) {
byte[] decoded = Base64.getDecoder().decode(bytes);
stream.write(decoded, 0, decoded.length);
}
}
</syntaxhighlight>
The operation is successful, creating a 48 by 48-pixel, 32-bit color graphic, at 15,086 bytes.
<br /><br />
An alternate demonstration
{{trans|Kotlin}}
{{trans|Kotlin}}
<lang java>import java.nio.charset.StandardCharsets;
<syntaxhighlight lang="java">import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Base64;


Line 759: Line 1,186:
System.out.println(decodedStr);
System.out.println(decodedStr);
}
}
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich</pre>
-- Paul R. Ehrlich</pre>

=={{header|JavaScript}}==
=== Browser ===
<syntaxhighlight lang="javascript">// define base64 data; in this case the data is the string: "Hello, world!"
const base64 = 'SGVsbG8sIHdvcmxkIQ==';
// atob is a built-in function.
console.log(atob(base64));</syntaxhighlight>
=== Node.js ===
<syntaxhighlight lang="javascript">// define base64 data; in this case the data is the string: "Hello, world!"
const base64 = Buffer.from('SGVsbG8sIHdvcmxkIQ==', 'base64');
// <Buffer>.toString() is a built-in method.
console.log(base64.toString());</syntaxhighlight>
{{out}}
<pre>Hello, world!</pre>


=={{header|jq}}==
=={{header|jq}}==
Line 773: Line 1,214:
See [[Base64_encode_data#Jsish]] for ''base64.jsi''.
See [[Base64_encode_data#Jsish]] for ''base64.jsi''.


<lang javascript>/* Base64 decode, in Jsish */
<syntaxhighlight lang="javascript">/* Base64 decode, in Jsish */
var data = exec('jsish base64.jsi', {retAll:true}).data; // or use File.read('stdin');
var data = exec('jsish base64.jsi', {retAll:true}).data; // or use File.read('stdin');
var icon = Util.base64(data, true);
var icon = Util.base64(data, true);
File.write('rosetta-favicon.ico', icon);</lang>
File.write('rosetta-favicon.ico', icon);</syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
Using an IOBuffer here, though not really needed to decode a string, shows how we could pipe a network stream or file though Julia's builtin Base64 decoder.
Using an IOBuffer here, though not really needed to decode a string, shows how we could pipe a network stream or file though Julia's builtin Base64 decoder.
<lang julia>using Base64
<syntaxhighlight lang="julia">using Base64


io = IOBuffer()
io = IOBuffer()
Line 791: Line 1,232:


println(String(read(iob64_decode)))
println(String(read(iob64_decode)))
</lang>{{out}}
</syntaxhighlight>{{out}}
<pre>
<pre>
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
Line 799: Line 1,240:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|D}}
{{trans|D}}
<lang scala>import java.util.Base64
<syntaxhighlight lang="scala">import java.util.Base64


fun main() {
fun main() {
Line 808: Line 1,249:
val decodedStr = String(decoded, Charsets.UTF_8)
val decodedStr = String(decoded, Charsets.UTF_8)
println(decodedStr)
println(decodedStr)
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
Line 814: Line 1,255:


=={{header|Lua}}==
=={{header|Lua}}==
<lang lua>-- Start taken from https://stackoverflow.com/a/35303321
<syntaxhighlight lang="lua">-- Start taken from https://stackoverflow.com/a/35303321
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding


Line 839: Line 1,280:


local decoded = dec(data)
local decoded = dec(data)
print(decoded)</lang>
print(decoded)</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
Line 845: Line 1,286:
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
--Paul R.Ehrlich</pre>
--Paul R.Ehrlich</pre>

=={{header|M2000 Interpreter}}==

=====Using a file and a Document object=====
Load.doc handle automatic UTF16LE UTF16BE UTF8 and ANSI. Also automatic find the type of new line (here is LF)

Tempname$ retuen a unique path+filename at temporary folder. The temporary file automatic deleted when the M2000 environment closed.

<syntaxhighlight lang="m2000 interpreter">
inp$={VG8gZXJyIGlzIGh1bWFuLCBidXQ
gdG8gcmVhbGx5IGZvdWwgdGhpbmdzI
HVwIHlvdSBuZWVkIGEgY29tcHV0ZXI
uCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
}
tmp$=tempname$
open tmp$ for wide output as #f
print #f, string$(inp$ as decode64);
close #f
document a$
load.doc a$, tmp$
report a$
clipboard a$
</syntaxhighlight>

=====Without File=====
If we know the encoding and type of line feed we can do this:

<syntaxhighlight lang="m2000 interpreter">
inp$={VG8gZXJyIGlzIGh1bWFuLCBidXQ
gdG8gcmVhbGx5IGZvdWwgdGhpbmdzI
HVwIHlvdSBuZWVkIGEgY29tcHV0ZXI
uCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
}
// decode inp$ (is 8-bit ANSI coded using 0xA for paragraph end/new line)
a$=string$(inp$ as Decode64)
locale 1033
// convert ansi to utf16le using Locale 1033
a$=chr$(a$) // convert to utf16LE
// expand LF to CRLF for M2000 console
a$=replace$(chr$(0xA), chr$(0XD)+chr$(0XA), a$)
// report handle cr and lf using proportional spacing for text and auto word wrapping
report a$
// also Print channel #-2 handle cr and lf (using non proportional spacing)
print #-2, a$
</syntaxhighlight>

{{out}}
<pre>
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich
</pre>


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>ImportString[
<syntaxhighlight lang="mathematica">ImportString[
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo",
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo",
"Base64"
"Base64"
]</lang>
]</syntaxhighlight>
{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
Line 856: Line 1,348:


=={{header|Nim}}==
=={{header|Nim}}==
<lang Nim>import base64
<syntaxhighlight lang="nim">import base64


const Source = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
const Source = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="


echo Source.decode()</lang>
echo Source.decode()</syntaxhighlight>


{{out}}
{{out}}
Line 875: Line 1,367:


=={{header|Ol}}==
=={{header|Ol}}==
<lang scheme>
<syntaxhighlight lang="scheme">
(define base64-codes "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
(define base64-codes "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
(define kernel (alist->ff (map cons (string->bytes base64-codes) (iota (string-length base64-codes)))))
(define kernel (alist->ff (map cons (string->bytes base64-codes) (iota (string-length base64-codes)))))
Line 912: Line 1,404:


(decode "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")
(decode "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")
</syntaxhighlight>
</lang>
{{Out}}
{{Out}}
<pre>
<pre>
Line 925: Line 1,417:
=={{header|Perl}}==
=={{header|Perl}}==
The MIME::Base64 module is to be preferred, but this works too.
The MIME::Base64 module is to be preferred, but this works too.
<lang perl>sub decode_base64 {
<syntaxhighlight lang="perl">sub decode_base64 {
my($d) = @_;
my($d) = @_;
$d =~ tr!A-Za-z0-9+/!!cd;
$d =~ tr!A-Za-z0-9+/!!cd;
Line 944: Line 1,436:
EOD
EOD


print decode_base64($data) . "\n";</lang>
print decode_base64($data) . "\n";</syntaxhighlight>
{{out}}
{{out}}
<pre>'Twas brillig, and the slithy toves
<pre>'Twas brillig, and the slithy toves
Line 952: Line 1,444:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>include builtins\base64.e
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
string s = "Rosetta Code Base64 decode data task"
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">base64</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
string e = encode_base64(s)
<span style="color: #004080;">string</span> <span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"Rosetta Code Base64 decode data task"</span>
?e
<span style="color: #004080;">string</span> <span style="color: #000000;">e</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">encode_base64</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
?decode_base64(e)</lang>
<span style="color: #0000FF;">?</span><span style="color: #000000;">e</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">decode_base64</span><span style="color: #0000FF;">(</span><span style="color: #000000;">e</span><span style="color: #0000FF;">)</span>
<!--</syntaxhighlight>-->
{{out}}
{{out}}
<pre>
<pre>
Line 964: Line 1,459:


=={{header|PHP}}==
=={{header|PHP}}==
<lang PHP>$encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw' .
<syntaxhighlight lang="php">$encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw' .
'IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
'IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
echo
echo
$encoded, PHP_EOL,
$encoded, PHP_EOL,
base64_decode($encoded), PHP_EOL;</lang>
base64_decode($encoded), PHP_EOL;</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 975: Line 1,470:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(setq *Char64
<syntaxhighlight lang="picolisp">(setq *Char64
`'(chop
`'(chop
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) )
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) )
Line 998: Line 1,493:
(link
(link
(char (| (>> -6 (& C 3)) D)) ) ) ) ) ) ) ) )
(char (| (>> -6 (& C 3)) D)) ) ) ) ) ) ) ) )
(prinl (decode64 "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"))</lang>
(prinl (decode64 "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"))</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,008: Line 1,503:
By necessity this also implements all of the Base64 encode task to
By necessity this also implements all of the Base64 encode task to
avoid a humongous amount of icon data hardcoded in the program.
avoid a humongous amount of icon data hardcoded in the program.
<syntaxhighlight lang="pike">
<lang Pike>
string icon = Protocols.HTTP.get_url_data("http://rosettacode.org/favicon.ico");
string icon = Protocols.HTTP.get_url_data("http://rosettacode.org/favicon.ico");
string encoded = MIME.encode_base64(icon);
string encoded = MIME.encode_base64(icon);
Stdio.write_file("favicon.ico", MIME.decode_base64(encoded));
Stdio.write_file("favicon.ico", MIME.decode_base64(encoded));
</syntaxhighlight>
</lang>


=={{header|Prolog}}==
=={{header|Prolog}}==
Line 1,027: Line 1,522:


=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>b64cd$ = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
<syntaxhighlight lang="purebasic">b64cd$ = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
"IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
"IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="


Line 1,033: Line 1,528:
Base64Decoder(b64cd$, *p_buf, 1024)
Base64Decoder(b64cd$, *p_buf, 1024)
OpenConsole("") : PrintN(PeekS(*p_buf, -1, #PB_UTF8))
OpenConsole("") : PrintN(PeekS(*p_buf, -1, #PB_UTF8))
Input()</lang>
Input()</syntaxhighlight>
{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
Line 1,039: Line 1,534:


=={{header|Python}}==
=={{header|Python}}==
<syntaxhighlight lang="python">
<lang Python>
import base64
import base64
data = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
data = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
print(base64.b64decode(data).decode('utf-8'))
print(base64.b64decode(data).decode('utf-8'))
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
Line 1,050: Line 1,545:
</pre>
</pre>
=={{header|QB64}}==
=={{header|QB64}}==
<lang vb>Option _Explicit
<syntaxhighlight lang="vb">Option _Explicit


Dim As String udata, decoded
Dim As String udata, decoded
Line 1,160: Line 1,655:
Wend
Wend
decode = sink
decode = sink
End Function</lang>
End Function</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,166: Line 1,661:
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
--Paul R.Ehrlich
--Paul R.Ehrlich
</pre>

=={{header|R}}==
===Using base64enc===
{{works with|R|4.1.0}}
{{libheader|base64enc}}
<syntaxhighlight lang="rsplus">
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo" |>
base64enc::base64decode() |>
rawToChar() |>
cat()
</syntaxhighlight>{{out}}
<pre>
To err is human, but to really foul things up you need a computer.
--Paul R.Ehrlich
</pre>

=={{header|Racket}}==
<syntaxhighlight lang="racket">
#lang racket
(require net/url net/base64)

;; decode a string
(displayln (base64-decode #"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="))

;; (encode and) decode the favicon
(displayln (base64-decode (base64-encode (call/input-url (string->url "https://rosettacode.org/favicon.ico")
get-pure-port port->bytes))))
</syntaxhighlight>
{{out}}
(string output only)
<pre>
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich
</pre>
</pre>


Line 1,172: Line 1,701:
{{works with|Rakudo|2018.11}}
{{works with|Rakudo|2018.11}}


<lang perl6>my $e64 = '
<syntaxhighlight lang="raku" line>my $e64 = '
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 1,197: Line 1,726:
say "\nFast:";
say "\nFast:";
use Base64::Native;
use Base64::Native;
say base64-decode($e64).decode('utf8');</lang>
say base64-decode($e64).decode('utf8');</syntaxhighlight>
{{out}}
{{out}}
<pre>Slow:
<pre>Slow:
Line 1,208: Line 1,737:


=={{header|Red}}==
=={{header|Red}}==
<lang red>Red [Source: https://github.com/vazub/rosetta-red]
<syntaxhighlight lang="red">Red [Source: https://github.com/vazub/rosetta-red]


print to-string debase "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
print to-string debase "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>
<pre>
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich
-- Paul R. Ehrlich
</pre>

=={{header|Ring}}==
<syntaxhighlight lang="ring">
#======================================#
# Sample: Base64 decode data
# Author: Gal Zsolt, Mansour Ayouni
#======================================#

load "guilib.ring"

oQByteArray = new QByteArray()
oQByteArray.append("Rosetta Code Base64 decode data task")
oba = oQByteArray.toBase64().data()
see oba + nl

oQByteArray = new QByteArray()
oQByteArray.append(oba)
see oQByteArray.fromBase64(oQByteArray).data()
</syntaxhighlight>
{{out}}
<pre>
Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr
Rosetta Code Base64 decode data task
</pre>

=={{header|RPL}}==
{{works with|RPL|HP-49C}}
« "" DUP DUP2 → s a b c d
« ""
1 s SIZE '''FOR''' j
0 3 '''FOR''' k
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
s j k + DUP SUB POS
'''NEXT'''
4 →LIST 1 - { a b c d } STO
a 4 * b 16 / IP + CHR +
'''IF''' c -1 ≠ '''THEN''' b 16 MOD 16 * c 4 / IP + CHR + '''END'''
'''IF''' d -1 ≠ '''THEN''' c 4 MOD 64 * d + CHR + '''END'''
4 '''STEP'''
» » '<span style="color:blue">B64→</span>' STO

"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=" <span style="color:blue">B64→</span>
{{out}}
<pre>
1: "To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich"
</pre>
</pre>


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>require 'base64'
<syntaxhighlight lang="ruby">require 'base64'


raku_example ='
raku_example ='
Line 1,225: Line 1,801:
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
'
'
puts Base64.decode64 raku_example</lang>
puts Base64.decode64 raku_example</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,233: Line 1,809:


=={{header|Rust}}==
=={{header|Rust}}==
<lang rust>use std::str;
<syntaxhighlight lang="rust">use std::str;


const INPUT: &str = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
const INPUT: &str = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
Line 1,270: Line 1,846:


println!("Output: {}", result);
println!("Output: {}", result);
}</lang>
}</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,280: Line 1,856:
=={{header|Scala}}==
=={{header|Scala}}==
{{Out}}Best seen in running your browser either by [https://scalafiddle.io/sf/mjgxJDp/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/P4RfGhRQSkaKWEmdBi1gaw Scastie (remote JVM)].
{{Out}}Best seen in running your browser either by [https://scalafiddle.io/sf/mjgxJDp/0 ScalaFiddle (ES aka JavaScript, non JVM)] or [https://scastie.scala-lang.org/P4RfGhRQSkaKWEmdBi1gaw Scastie (remote JVM)].
<lang Scala>import java.util.Base64
<syntaxhighlight lang="scala">import java.util.Base64


object Base64Decode extends App {
object Base64Decode extends App {
Line 1,293: Line 1,869:


println(text2BinaryDecoding(data))
println(text2BinaryDecoding(data))
}</lang>
}</syntaxhighlight>


=={{header|Seed7}}==
=={{header|Seed7}}==
Line 1,300: Line 1,876:
[http://seed7.sourceforge.net/libraries/encoding.htm#fromBase64(in_string) fromBase64].
[http://seed7.sourceforge.net/libraries/encoding.htm#fromBase64(in_string) fromBase64].


<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "gethttp.s7i";
include "gethttp.s7i";
include "encoding.s7i";
include "encoding.s7i";
Line 1,313: Line 1,889:
writeln("Is the Rosetta Code icon the same (byte for byte) encoded then decoded: " <&
writeln("Is the Rosetta Code icon the same (byte for byte) encoded then decoded: " <&
fromBase64(encoded) = original);
fromBase64(encoded) = original);
end func;</lang>
end func;</syntaxhighlight>


{{out}}
{{out}}
<pre>Is the Rosetta Code icon the same (byte for byte) encoded then decoded: TRUE</pre>
<pre>Is the Rosetta Code icon the same (byte for byte) encoded then decoded: TRUE</pre>

=={{header|SenseTalk}}==
<syntaxhighlight lang="sensetalk">

put base64Decode ("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuIC0tUGF1bCBSLkVocmxpY2g=")

</syntaxhighlight>

Output:
<syntaxhighlight lang="sensetalk">To err is human, but to really foul things up you need a computer. --Paul R.Ehrlich</syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>var data = <<'EOT'
<syntaxhighlight lang="ruby">var data = <<'EOT'
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
EOT
EOT


say data.decode_base64</lang>
say data.decode_base64</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,333: Line 1,919:
=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<lang smalltalk>data := '
<syntaxhighlight lang="smalltalk">data := '
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
'.
'.


data base64Decoded asString printCR.</lang>
data base64Decoded asString printCR.</syntaxhighlight>
{{out}}
{{out}}
<pre>To err is human, but to really foul things up you need a computer.
<pre>To err is human, but to really foul things up you need a computer.
Line 1,344: Line 1,930:


=={{header|Standard ML}}==
=={{header|Standard ML}}==
<lang Standard ML>val debase64 = fn input =>
<syntaxhighlight lang="sml">val debase64 = fn input =>
let
let


Line 1,374: Line 1,960:
String.implode ( List.map (chr o Word.toInt) ( decodeLst (String.explode input )) )
String.implode ( List.map (chr o Word.toInt) ( decodeLst (String.explode input )) )


end handle Subscript => "Invalid code\n" ;</lang>
end handle Subscript => "Invalid code\n" ;</syntaxhighlight>
call
call
<pre>
<pre>
Line 1,382: Line 1,968:
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich </pre>
-- Paul R. Ehrlich </pre>

=={{header|Swift}}==
<syntaxhighlight lang="swift">
import Foundation

let input = """
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
"""

if let decoded = Data(base64Encoded: input),
let str = String(data: decoded, encoding: .utf8) {
print( str )
}
</syntaxhighlight>
<pre>
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich
</pre>

=={{header|Tcl}}==
=={{header|Tcl}}==
<lang tcl>package require tcl 8.6
<syntaxhighlight lang="tcl">package require tcl 8.6
set data VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
set data VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=


puts [binary decode base64 $data]</lang>
puts [binary decode base64 $data]</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,395: Line 2,000:
=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{trans|D}}
{{trans|D}}
<lang vbnet>Module Module1
<syntaxhighlight lang="vbnet">Module Module1


Sub Main()
Sub Main()
Line 1,406: Line 2,011:
End Sub
End Sub


End Module</lang>
End Module</syntaxhighlight>
{{out}}
{{out}}
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
<pre>VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 1,412: Line 2,017:
To err is human, but to really foul things up you need a computer.
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich</pre>
-- Paul R. Ehrlich</pre>

=={{header|V (Vlang)}}==
<syntaxhighlight lang="v (vlang)">import encoding.base64

fn main() {
msg := "Rosetta Code Base64 decode data task"
println("Original : $msg")
encoded := base64.encode_str(msg)
println("\nEncoded : $encoded")
decoded := base64.decode_str(encoded)
println("\nDecoded : $decoded")
}</syntaxhighlight>

{{out}}
<pre>
Original : Rosetta Code Base64 decode data task

Encoded : Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr

Decoded : Rosetta Code Base64 decode data task
</pre>


=={{header|Wren}}==
=={{header|Wren}}==
Line 1,417: Line 2,043:
{{libheader|Wren-str}}
{{libheader|Wren-str}}
From first principles using string manipulation. Quick enough here.
From first principles using string manipulation. Quick enough here.
<lang ecmascript>import "io" for Stdout
<syntaxhighlight lang="wren">import "io" for Stdout
import "/fmt" for Conv, Fmt
import "./fmt" for Conv, Fmt
import "/str" for Str
import "./str" for Str


var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Line 1,446: Line 2,072:
var s = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
var s = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
for (chunk in Str.chunks(s, 4)) decode.call(chunk)
for (chunk in Str.chunks(s, 4)) decode.call(chunk)
System.print()</lang>
System.print()</syntaxhighlight>


{{out}}
{{out}}
Line 1,453: Line 2,079:
-- Paul R. Ehrlich
-- Paul R. Ehrlich
</pre>
</pre>

=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">func Decode(Ch);
int Ch;
[if Ch>=^A & Ch<=^Z then return Ch - ^A;
if Ch>=^a & Ch<=^z then return Ch - ^a + 26;
if Ch>=^0 & Ch<=^9 then return Ch - ^0 + 52;
if Ch = ^+ then return 62;
if Ch = ^/ then return 63;
return -1;
];

char Str;
int Count, N, Ch, Code, Acc;
[Str:=
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEg
Y29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo ";
loop [Count:= 0;
for N:= 1 to 4 do \read in four 6-bit chars
[repeat Ch:= Str(0); \strip out whitespace
Str:= Str+1;
if Ch = $A0 then quit; \terminating space
until Ch > $20;
Code:= Decode(Ch);
Acc:= Acc<<6;
if Code >= 0 then \don't count possible "="
[Acc:= Acc + Code;
Count:= Count+1;
];
];
ChOut(0, Acc>>16); \write out three 8-bit chars
if Count >= 3 then ChOut(0, Acc>>8);
if Count >= 4 then ChOut(0, Acc);
];
]</syntaxhighlight>
{{out}}
<pre>
To err is human, but to really foul things up you need a computer.
--Paul R.Ehrlich</pre>


=={{header|zkl}}==
=={{header|zkl}}==
Using shared libraries for cURL and message hashing:
Using shared libraries for cURL and message hashing:
<lang zkl>var [const] MsgHash=Import("zklMsgHash"), Curl=Import("zklCurl");
<syntaxhighlight lang="zkl">var [const] MsgHash=Import("zklMsgHash"), Curl=Import("zklCurl");
icon:=Curl().get("http://rosettacode.org/favicon.ico"); //-->(Data(4,331),693,0)
icon:=Curl().get("http://rosettacode.org/favicon.ico"); //-->(Data(4,331),693,0)
Line 1,464: Line 2,129:
File("rosettaCodeIcon.ico","wb").write(iconDecoded); # eyeball checking says good
File("rosettaCodeIcon.ico","wb").write(iconDecoded); # eyeball checking says good
println("Is the Rosetta Code icon the same (byte for byte) encoded then decoded: ",
println("Is the Rosetta Code icon the same (byte for byte) encoded then decoded: ",
icon==iconDecoded);</lang>
icon==iconDecoded);</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 1,470: Line 2,135:
</pre>
</pre>
{{out|Text based test}}
{{out|Text based test}}
<lang zkl>msg,b64 := "Rosetta Code Base64 decode data task", MsgHash.base64encode(msg);
<syntaxhighlight lang="zkl">msg,b64 := "Rosetta Code Base64 decode data task", MsgHash.base64encode(msg);
println("Original: %s\nEncoded: %s\nBytes: %s\nDecoded: %s"
println("Original: %s\nEncoded: %s\nBytes: %s\nDecoded: %s"
.fmt(msg, b64.text, b64.bytes().apply("toString",16).concat(","),
.fmt(msg, b64.text, b64.bytes().apply("toString",16).concat(","),
MsgHash.base64decode(b64).text));</lang>
MsgHash.base64decode(b64).text));</syntaxhighlight>
<pre>
<pre>
Original: Rosetta Code Base64 decode data task
Original: Rosetta Code Base64 decode data task

Latest revision as of 15:25, 14 April 2024

Task
Base64 decode data
You are encouraged to solve this task according to the task description, using any language you may know.

See Base64 encode data.

Now write a program that takes the output of the Base64 encode data task as input and regenerate the original file.

When working on the VBA implementation I found several 'solutions' on the net, including one from the software maker himself, that showed output with incorrect padding. Obviously with incorrect padding in the output you can not decode correctly to the original file again.

Action!

BYTE FUNC FindIndex(BYTE b)
  IF b>='A AND b<='Z THEN
    RETURN (b-'A)
  ELSEIF b>='a AND b<='z THEN
    RETURN (b-'a+26)
  ELSEIF b>='0 AND b<='9 THEN
    RETURN (b-'0+52)
  ELSEIF b='+ THEN
    RETURN (62)
  ELSEIF b='/ THEN
    RETURN (63)
  FI
RETURN (-1)

PROC PrintChar(CHAR c)
  IF c=10 THEN
    PutE()
  ELSE
    Put(c)
  FI
RETURN

PROC Decode(CHAR ARRAY s)
  BYTE i,b1,b2,b3,b4,i1,i2,i3,i4
  CHAR c

  IF s(0) MOD 4#0 THEN
    PrintE("Invalid length of string!!!")
    Break()
  FI

  i=1
  WHILE i<=s(0)
  DO
    b1=s(i) i==+1
    b2=s(i) i==+1
    b3=s(i) i==+1
    b4=s(i) i==+1

    i1=FindIndex(b1)
    i2=FindIndex(b2)

    c=i1 LSH 2
    c==%i2 RSH 4
    PrintChar(c)

    IF b3#'= THEN
      i3=FindIndex(b3)
      c=(i2&$0F) LSH 4
      c==%i3 RSH 2
      PrintChar(c)

      IF b4#'= THEN
        i4=FindIndex(b4)
        c=(i3&$03) LSH 6
        c==%i4
        PrintChar(c)
      FI
    FI
  OD
RETURN

PROC Test(CHAR ARRAY s)
  PrintE("Encoded:")
  PrintE(s)
  PutE()
  PrintE("Decoded:")
  Decode(s)
  PutE()
RETURN

PROC Main()
  Test("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo")
RETURN
Output:

Screenshot from Atari 8-bit computer

Encoded:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo

Decoded:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Ada

Library: AWS
with Ada.Text_IO;

with AWS.Translator;

procedure Decode_AWS is
   Input  : constant String :=
     "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" &
     "IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
   Result : constant String := AWS.Translator.Base64_Decode (Input);
begin
   Ada.Text_IO.Put_Line (Input);
   Ada.Text_IO.New_Line;
   Ada.Text_IO.Put_Line (Result);
end Decode_AWS;
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Arturo

text: "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="

print decode text
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Bash

Translation of: Bash
#! /bin/bash
declare -a encodeTable=(
# +   ,   -   .   /   0   1   2   3   4   5   6   7   8   9   :
 62  -1  -1  -1  63  52  53  54  55  56  57  58  59  60  61  -1
# ;   <   =   >   ?   @   A   B   C   D   E   F   G   H   I   J
 -1  -1  -1  -1  -1  -1   0   1   2   3   4   5   6   7   8   9
# K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
 10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25
# [   \   ]   ^   _   `   a   b   c   d   e   f   g   h   i   j
 -1  -1  -1  -1  -1  -1  26  27  28  29  30  31  32  33  34  35 
# k   l   m   n   o   p   q   r   s   t   u   v   w   x   y   z
 36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51
)
function a2b6()
{
    if [ $1 -lt 43 -o $1 -gt 122 ]
    then
        echo -1
    else
        echo ${encodeTable[$(($1-43))]}
    fi
}

function flush() {
    for (( k=2; k>=4-CNT; k-- ))
    do
        (( b8=BUF>>(k*8)&255 ))
        printf -v HEX %x $b8
        printf \\x$HEX
    done
}

while read INPUT
do
    for (( i=0; i<${#INPUT}; i++ ))
    do
        printf -v NUM %d "'${INPUT:$i:1}"
        if (( NUM==61 ))
        then
            flush
            exit 0
        else
            DEC=$( a2b6 $NUM )
            if (( DEC>=0 ))
            then
                (( BUF|=DEC<<6*(3-CNT) ))
                if (( ++CNT==4 ))
                then
                    flush
                    (( CNT=0, BUF=0 ))
                fi
            fi
        fi
    done
done

BASIC

BaCon

Using the result from the Base64 encode data task as requested, but the result is abbreviated in the code below.

data$ = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAE.......QAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="
ico$ = B64DEC$(data$)
BSAVE ico$ TO "favicon.ico" SIZE LEN(ico$)

C

Translation of: C++
#include <stdio.h>
#include <stdlib.h>

typedef unsigned char ubyte;
const ubyte BASE64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

int findIndex(const ubyte val) {
    if ('A' <= val && val <= 'Z') {
        return val - 'A';
    }
    if ('a' <= val && val <= 'z') {
        return val - 'a' + 26;
    }
    if ('0' <= val && val <= '9') {
        return val - '0' + 52;
    }
    if (val == '+') {
        return 62;
    }
    if (val == '/') {
        return 63;
    }
    return -1;
}

int decode(const ubyte source[], ubyte sink[]) {
    const size_t length = strlen(source);
    const ubyte *it = source;
    const ubyte *end = source + length;
    int acc;

    if (length % 4 != 0) {
        return 1;
    }

    while (it != end) {
        const ubyte b1 = *it++;
        const ubyte b2 = *it++;
        const ubyte b3 = *it++;         // might be the first padding byte
        const ubyte b4 = *it++;         // might be the first or second padding byte

        const int i1 = findIndex(b1);
        const int i2 = findIndex(b2);

        acc = i1 << 2;                  // six bits came from the first byte
        acc |= i2 >> 4;                 // two bits came from the first byte
        *sink++ = acc;                  // output the first byte

        if (b3 != '=') {
            const int i3 = findIndex(b3);

            acc = (i2 & 0xF) << 4;      // four bits came from the second byte
            acc += i3 >> 2;             // four bits came from the second byte
            *sink++ = acc;              // output the second byte

            if (b4 != '=') {
                const int i4 = findIndex(b4);

                acc = (i3 & 0x3) << 6;  // two bits came from the third byte
                acc |= i4;              // six bits came from the third byte
                *sink++ = acc;          // output the third byte
            }
        }
    }

    *sink = '\0';   // add the sigil for end of string
    return 0;
}

int main() {
    ubyte data[] = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
    ubyte decoded[1024];

    printf("%s\n\n", data);
    decode(data, decoded);
    printf("%s\n\n", decoded);

    return 0;
}
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo

To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

C#

Translation of: Visual Basic .NET
using System;
using System.Text;

namespace Base64DecodeData {
    class Program {
        static void Main(string[] args) {
            var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
            Console.WriteLine(data);
            Console.WriteLine();

            var decoded = Encoding.ASCII.GetString(Convert.FromBase64String(data));
            Console.WriteLine(decoded);
        }
    }
}
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

C++

Works with: C++14
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef unsigned char ubyte;
const auto BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

std::vector<ubyte> encode(const std::vector<ubyte>& source) {
    auto it = source.cbegin();
    auto end = source.cend();

    std::vector<ubyte> sink;
    while (it != end) {
        auto b1 = *it++;
        int acc;

        sink.push_back(BASE64[b1 >> 2]);            // first output (first six bits from b1)

        acc = (b1 & 0x3) << 4;                      // last two bits from b1
        if (it != end) {
            auto b2 = *it++;
            acc |= (b2 >> 4);                       // first four bits from b2

            sink.push_back(BASE64[acc]);            // second output

            acc = (b2 & 0xF) << 2;                  // last four bits from b2
            if (it != end) {
                auto b3 = *it++;
                acc |= (b3 >> 6);                   // first two bits from b3

                sink.push_back(BASE64[acc]);        // third output
                sink.push_back(BASE64[b3 & 0x3F]);  // fouth output (final six bits from b3)
            } else {
                sink.push_back(BASE64[acc]);        // third output
                sink.push_back('=');                // fourth output (1 byte padding)
            }
        } else {
            sink.push_back(BASE64[acc]);            // second output
            sink.push_back('=');                    // third output (first padding byte)
            sink.push_back('=');                    // fourth output (second padding byte)
        }
    }
    return sink;
}

int findIndex(ubyte val) {
    if ('A' <= val && val <= 'Z') {
        return val - 'A';
    }
    if ('a' <= val && val <= 'z') {
        return val - 'a' + 26;
    }
    if ('0' <= val && val <= '9') {
        return val - '0' + 52;
    }
    if ('+' == val) {
        return 62;
    }
    if ('/' == val) {
        return 63;
    }
    return -1;
}

std::vector<ubyte> decode(const std::vector<ubyte>& source) {
    if (source.size() % 4 != 0) {
        throw new std::runtime_error("Error in size to the decode method");
    }

    auto it = source.cbegin();
    auto end = source.cend();

    std::vector<ubyte> sink;
    while (it != end) {
        auto b1 = *it++;
        auto b2 = *it++;
        auto b3 = *it++; // might be first padding byte
        auto b4 = *it++; // might be first or second padding byte

        auto i1 = findIndex(b1);
        auto i2 = findIndex(b2);
        auto acc = i1 << 2;     // six bits came from the first byte
        acc |= i2 >> 4;         // two bits came from the first byte

        sink.push_back(acc);    // output the first byte

        if (b3 != '=') {
            auto i3 = findIndex(b3);

            acc = (i2 & 0xF) << 4;  // four bits came from the second byte
            acc |= i3 >> 2;         // four bits came from the second byte

            sink.push_back(acc);    // output the second byte

            if (b4 != '=') {
                auto i4 = findIndex(b4);

                acc = (i3 & 0x3) << 6;  // two bits came from the third byte
                acc |= i4;              // six bits came from the third byte

                sink.push_back(acc);    // output the third byte
            }
        }
    }
    return sink;
}

int main() {
    using namespace std;

    string data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
    vector<ubyte> datav{ begin(data), end(data) };
    cout << data << "\n\n" << decode(datav).data() << endl;

    return 0;
}
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo

To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Caché ObjectScript

USER>Write $System.Encryption.Base64Decode("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")
To err is human, but to really foul things up you need a computer.
                                                                      -- Paul R. Ehrlich

Clojure

(defn decode [str]
  (String. (.decode (java.util.Base64/getDecoder) str)))

(decode "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")
Output:
"To err is human, but to really foul things up you need a computer.\n    -- Paul R. Ehrlich"

Common Lisp

Similar to the BASE64 encoding task I am using the cl-base64 library.

(eval-when (:load-toplevel :compile-toplevel :execute)
  (ql:quickload "cl-base64"))

;; * The package definition
(defpackage :base64-decode
  (:use :common-lisp :cl-base64))
(in-package :base64-decode)

;; * The encoded data
(defvar *base64-data*
  "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wCGiYcARkhHAL/CwAAmKScAam1rAOPm5ACgo6EAV1pYABcZGADO0c8AODs5AK2wrgBzdnQA6+7sAPz//QAAAwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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0t36g+Evk5EtLS0tLS0tLS0tLS0sBAekAi0ykLQR0LAomkOIBAQEBAQEBAQEBAQEBAQEBAQEB6QDkAQHkbRnnAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAOaFhYbu7zPmhYWF5oaGhoaGhoaGhoaGhoaGhoaFhekA/////wAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="
 "See BASE64-ENCODE for the origin of this
 data. http://rosettacode.org/wiki/Base64_encode_data")

;; * The function
(defun base64-decode (&optional (data *base64-data*) (file #p"favicon-2.ico"))
  "Returns the original FILE BASE64 encoded in DATA."
  (with-open-file (stream file :direction :output :element-type 'unsigned-byte
                          :if-exists :supersede :if-does-not-exist :create)
    (let* ((array (base64-string-to-usb8-array data))
           (len (length array)))
      (write-sequence array stream)
      (format t "Wrote ~D bytes in file ~A~%" len file))))
Output:
Wrote 3638 bytes in file favicon-2.ico

Crystal

require "base64"

encoded_string = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="

decoded_string = Base64.decode_string(encoded_string)
puts decoded_string
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

D

Translation of: Raku
import std.base64;
import std.stdio;

void main() {
    auto data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
    writeln(data);
    writeln;

    auto decoded = cast(char[])Base64.decode(data);
    writeln(decoded);
}
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Dart

import 'dart:convert';

void main() {
  var encoded = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
  var decoded = utf8.decode(base64.decode(encoded));
  print(decoded); 
}
Output:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Delphi

program Base64Decoder;

{$APPTYPE CONSOLE}

uses
  System.SysUtils, System.NetEncoding;

const
  Src = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';

begin
  WriteLn(Format('Source string: ' + sLineBreak + '"%s"', [Src]));
  WriteLn(Format('Decoded string: ' + sLineBreak + '"%s"', [TNetEncoding.Base64.Decode(Src)]));

end.
Output:
Source string:
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
Decoded string:
"To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich"

Ecstasy

/**
 * This implementation is encapsulated as Base64Format in the web.xtclang.org module,
 * but the module is currently in flux, so the implementation is included "inline" here.
 */
module Base64 {
    @Inject Console console;
    void run() {
        String orig  = \|VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIH\
                        |lvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
                       ;
        Byte[] bytes = decode(orig);
        String text  = encode(bytes, pad=True);
        assert text == orig;
        console.print($"base64={text}, bytes={bytes}");
    }

    static Byte[] read(Iterator<Char> stream) {
        Int    charLen    = 0;
        charLen := stream.knownSize();
        Byte[] byteBuf    = new Byte[](charLen * 6 / 8);
        Byte   prevBits   = 0;
        Int    prevCount  = 0;
        while (Char ch := stream.next()) {
            if (Byte newBits := isBase64(ch, assertTrash=True)) {
                if (prevCount == 0) {
                    prevBits  = newBits;
                    prevCount = 6;
                } else {
                    byteBuf.add((prevBits << 8-prevCount) | (newBits >> prevCount-2));
                    prevBits   = newBits;
                    prevCount -= 2;
                }
            }
        }

        return byteBuf.freeze(True);
    }

    static void write(Byte[] value, Appender<Char> stream, Boolean pad=False, Int? lineLength=Null) {
        lineLength ?:= Int.MaxValue;

        Int    lineOffset = 0;
        Int    totalChars = 0;
        Byte   prevByte   = 0;
        Int    prevCount  = 0;          // number of leftover bits from the previous byte
        Int    byteOffset = 0;
        Int    byteLength = value.size;
        while (True) {
            // glue together the next six bits, which will create one character of output
            Byte sixBits;
            if (byteOffset >= byteLength) {
                if (prevCount == 0) {
                    break;
                }
                sixBits   = prevByte << 6 - prevCount;
                prevCount = 0;
            } else if (prevCount == 6) {
                sixBits   = prevByte << 6 - prevCount;
                prevCount = 0;
            } else {
                Byte nextByte = value[byteOffset++];
                sixBits    = (prevByte << 6 - prevCount) | (nextByte >> 2 + prevCount);
                prevByte   = nextByte;
                prevCount += 2;
            }

            if (lineOffset >= lineLength) {
                stream.add('\r').add('\n');
                totalChars += lineOffset;
                lineOffset  = 0;
            }

            stream.add(base64(sixBits & 0b111111));
            ++lineOffset;
        }

        if (pad) {
            totalChars += lineOffset;
            for (Int i = 0, Int padCount = 4 - (totalChars & 0b11) & 0b11; i < padCount; ++i) {
                if (lineOffset >= lineLength) {
                    stream.add('\r').add('\n');
                    lineOffset  = 0;
                }

                stream.add('=');
                ++lineOffset;
            }
        }
    }

    static String encode(Byte[] value, Boolean pad=False, Int? lineLength=Null) {
        // calculate buffer size
        Int byteLen = value.size;
        Int charLen = (byteLen * 8 + 5) / 6;
        if (pad) {
            charLen += 4 - (charLen & 0b11) & 0b11;
        }
        if (lineLength != Null) {
            charLen += ((charLen + lineLength - 1) / lineLength - 1).maxOf(0) * 2;
        }

        StringBuffer charBuf = new StringBuffer(charLen);
        write(value, charBuf, pad, lineLength);
        return charBuf.toString();
    }

    static Byte[] decode(String text) {
        Int    charLen    = text.size;
        Byte[] byteBuf    = new Byte[](charLen * 6 / 8);
        Byte   prevBits   = 0;
        Int    prevCount  = 0;
        for (Int offset = 0; offset < charLen; ++offset) {
            if (Byte newBits := isBase64(text[offset], assertTrash=True)) {
                if (prevCount == 0) {
                    prevBits  = newBits;
                    prevCount = 6;
                } else {
                    byteBuf.add((prevBits << 8-prevCount) | (newBits >> prevCount-2));
                    prevBits   = newBits;
                    prevCount -= 2;
                }
            }
        }

        return byteBuf.freeze(True);
    }

    /**
     * Translate a single Base64 character to the least significant 6 bits of a `Byte` value.
     *
     * @param ch  the Base64 character; no pad or newlines allowed
     *
     * @return the value in the range `0 ..< 64`
     */
    static Byte valOf(Char ch) {
        return switch (ch) {
            case 'A'..'Z': (ch - 'A').toUInt8();
            case 'a'..'z': (ch - 'a').toUInt8() + 26;
            case '0'..'9': (ch - '0').toUInt8() + 52;
            case '+': 62;
            case '/': 63;

            case '=':        assert as $"Unexpected padding character in Base64: {ch.quoted()}";
            case '\r', '\n': assert as $"Unexpected newline character in Base64: {ch.quoted()}";
            default:         assert as $"Invalid Base64 character: {ch.quoted()}";
        };
    }

    /**
     * Translate a single Base64 character to the least significant 6 bits of a `Byte` value.
     *
     * @param ch           the character to test if it is Base64
     * @param assertTrash  (optional) pass True to assert on illegal Base64 characters
     *
     * @return the value in the range `0 ..< 64`
     */
    static conditional Byte isBase64(Char ch, Boolean assertTrash=False) {
        return switch (ch) {
            case 'A'..'Z': (True, (ch - 'A').toUInt8());
            case 'a'..'z': (True, (ch - 'a').toUInt8() + 26);
            case '0'..'9': (True, (ch - '0').toUInt8() + 52);
            case '+': (True, 62);
            case '/': (True, 63);

            case '=':           // "pad" sometimes allowed (or required) at end
            case '\r', '\n':    // newlines sometimes allowed (or required)
                False;

            default: assertTrash ? assert as $"Invalid Base64 character: {ch.quoted()}" : False;
        };
    }

    /**
     * Convert the passed byte value to a Base64 character.
     *
     * @param the byte value, which must be in the range `0..63`
     *
     * @return the Base64 character
     */
    static Char base64(Byte byte) {
        return switch (byte) {
            case  0 ..< 26: 'A'+byte;
            case 26 ..< 52: 'a'+(byte-26);
            case 52 ..< 62: '0'+(byte-52);
            case 62: '+';
            case 63: '/';
            default: assert:bounds as $"byte={byte}";
        };
    }
}
Output:
base64=VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=, bytes=0x546F206572722069732068756D616E2C2062757420746F207265616C6C7920666F756C207468696E677320757020796F75206E656564206120636F6D70757465722E0A202020202D2D205061756C20522E204568726C696368

F#

Standard Library

open System
open System.IO

let encoded = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wCGiYcARkhHAL/CwAAmKScAam1rAOPm5ACgo6EAV1pYABcZGADO0c8AODs5AK2wrgBzdnQA6+7sAPz//QAAAwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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hekA/////wAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="

let decoded = Convert.FromBase64String encoded

File.WriteAllBytes("favicon.ico", decoded)
Output:

Rosetta Code Icon

Manual Implementation

open System
open System.IO

let encoded = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAEAAAACAAAAABAAgAAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wCGiYcARkhHAL/CwAAmKScAam1rAOPm5ACgo6EAV1pYABcZGADO0c8AODs5AK2wrgBzdnQA6+7sAPz//QAAAwEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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B1+9BwvWY6h0VyMZAFFeEmdQAQHyn8Bnr3VCAQEBk1EToClTlpDw80zqAeYAJj4lF08BhdF+L1lqUIcBAQHkM/Dwi+6G5OLi4gEB5gCYAo9oJAF7fjFbRoMBAQFL4gEBAQEBAQEBAQEBAQHpAFC3INQVmFhbZAJV6wEB5Evk5OLi4uLi4uTk5OQBAekAEUGKyRi/qhQDwU0BAeRLS0tLS0tLS0tLS0tLSwEB6QDNYQY1DmdkVKF/nWyF5EtLS0tLS0tLS0tLS0tLAQHpABFBinK4IkbYs7d+KfXj5EtLS0tLS0tLS0tLS0sBAekAmGkgLidwkgq5L69+/gEBS0tLS0tLS0tLS0tLSwEB6QAm2jyzAQEBhqxanr8kAQFLS0tLS0tLS0tLS0tLAQHpAJjaJS4FR43P2VkORssBAUtLS0tLS0tLS0tLS0sBAekAUNiEKrlFOkGrZbALIwEBS0tLS0tLS0tLS0tLSwEB6QBPwjwoMduzNh6puZ/wAeJLS0tLS0tLS0tLS0tLAQHpAPl0d6u3wDi0t36g+Evk5EtLS0tLS0tLS0tLS0sBAekAi0ykLQR0LAomkOIBAQEBAQEBAQEBAQEBAQEBAQEB6QDkAQHkbRnnAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAOaFhYbu7zPmhYWF5oaGhoaGhoaGhoaGhoaGhoaFhekA/////wAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="


let decode (s: string) =
    let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".ToCharArray()
    let filtered = String.filter (fun c -> Array.contains c chars || c = '=') s
    let paddingSize = filtered |> String.filter ((=) '=') |> String.length
    let s = filtered.Replace('=', 'A').ToCharArray() |> Array.map int
    let ints = chars |> Array.map int
    let calc c =
        let n = [c..(c + 3)]
                |> List.sumBy (fun k -> Array.IndexOf(ints, s.[k]) <<< (18 - 6 * (k % 4)))
        [16; 8; 0]
        |> List.map (fun k -> (n >>> k) &&& 255 |> char |> string) |> List.reduce (+)
    [0..4..Array.length s - 1]
    |> List.map calc
    |> List.reduce (+)
    |> fun r -> r.Substring(0, String.length r - paddingSize).ToCharArray()
    |> Array.map byte

let decoded = decode encoded

File.WriteAllBytes("favicon.ico", decoded)
Output:

Rosetta Code Icon

Factor

USING: base64 io strings ;

"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
base64> >string print
Output:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich



Forth

Works with: gforth version 0.7.3

Inspired from Wikipedia. Use of a buffer. May be also of interest : github.com/lietho/base64-forth

variable bitsbuff

: char>6bits ( c -- u )
   dup 43 =          if drop 62   exit then    ( + case )
   dup 47 =          if drop 63   exit then    ( / case )
   dup 48 58 within  if 48 - 52 + exit then    ( 0-9 case )
   dup 65 91 within  if 65 -      exit then    ( A-Z case )
   dup 97 123 within if 97 - 26 + exit then    ( a-z case )
   drop 0                                      ( padding )
;
: 6bitsin ( v -- ) bitsbuff @ 6 lshift + bitsbuff ! ;
: 4charsin ( addr -- addr+4 )
   $0 bitsbuff !
   dup 4 + dup rot
   do I c@ char>6bits 6bitsin loop ;
: 3bytes, ( -- )
   bitsbuff @ 16 rshift $ff and c,
   bitsbuff @  8 rshift $ff and c,
   bitsbuff @           $ff and c, ;


: b64dec ( addr1 n1 -- addr2 n2 )
   here rot rot ( addr2 addr1 n1 )
   4 /          ( addr2 addr1 n1/4 )
   0 do
      4charsin 3bytes,
   loop                                   ( addr2 addr1+4x )
   ( get back for padding )
   1 - dup c@ 61 = if 1 else 0 then swap  ( addr2 0|1 addr1+4x-1 )
   1 -     c@ 61 = if 1 else 0 then +     ( addr2 0|1|2 )
   swap            ( 0|1|2 addr2 )
   dup here swap - ( 0|1|2 addr2 n' )
   rot -           ( addr2 n2 )
;
Output:
s" VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo" b64dec cr type cr 
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich
 ok

( encode with b64enc as coded for Base64 encode data task )
s" VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo" b64dec b64enc cr type 
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo ok

s" YW55IGNhcm5hbCBwbGVhc3VyZS4=" b64dec cr type cr
any carnal pleasure.
 ok

s" YW55IGNhcm5hbCBwbGVhc3VyZQ==" b64dec cr type cr 
any carnal pleasure
 ok


FreeBASIC

Dim Shared As String B64
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
"abcdefghijklmnopqrstuvwxyz" & _
"0123456789+/"

Function MIMEDecode(s As String ) As Integer
    If Len(s) Then
        MIMEdecode = Instr(B64,s) - 1
    Else
        MIMEdecode = -1
    End If
End Function

Function Decode64(s As String) As String
    Dim As Integer w1, w2, w3, w4
    Dim As String  mD
    For n As Integer = 1 To Len(s) Step 4
        w1 = MIMEdecode(Mid(s,n+0,1))
        w2 = MIMEdecode(Mid(s,n+1,1))
        w3 = MIMEdecode(Mid(s,n+2,1))
        w4 = MIMEdecode(Mid(s,n+3,1))
        If w2 >-1 Then mD+= Chr(((w1* 4 + Int(w2/16)) And 255))
        If w3 >-1 Then mD+= Chr(((w2*16 + Int(w3/ 4)) And 255))
        If w4 >-1 Then mD+= Chr(((w3*64 + w4        ) And 255))
    Next n
    Return mD
End Function

Dim As String msg64 = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" & _
"IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
Print msg64
Print: Print(Decode64(msg64))
Sleep
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Frink

This reproduces the Rosetta Code icon as specified in the Base64 encode data task.

s="""iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xh
BQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAA
OpgAABdwnLpRPAAAAWJQTFRFAAAA/8IA/8EA/8IA/8IA/8IA/8IA/8IA/8IA/8IA
/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA
/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8UA/8UA/8QA/8IA/8IA/8IA/8IA/8IA
/8IA/8MAdWVhiHJUiHJUc2Rj/8MA/8IA/8IA/8IA/8IA/8IA06QfjXZQjnZQjXVR
3qwX/8IA/8IA/8IA/8IA/8IA/8kAjHVRjnZQjnZQjHVR/8gA/8IA/8IA/8IAjHVR
jHVR/8gA/8IA/8IA1aYejXZQjnZQjXVR3qwX/8IA/8IA/8IA/8MAdGRjh3FVcmNj
/8MA/8IA/8QA/8UA/8UA/8UA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA/8IA
/8IA/8IA/8IA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WUAMTQzODU0Nzk1MNul3mEAAAAPdEVY
dFRodW1iOjpTaXplADBCQpSiPuwAAABWdEVYdFRodW1iOjpVUkkAZmlsZTovLy9t
bnRsb2cvZmF2aWNvbnMvMjAxNS0wOC0wMi8xNDBkYmM4M2RmNWY3NmQyNmIzYWNl
M2ZlYTViYzI5ZS5pY28ucG5nBect2gAAAABJRU5ErkJggg=="""

f = newJava["java.io.FileOutputStream", ["favicon.ico"]]
f.write[base64DecodeToBytes[s]]
f.close[]

FutureBasic

include "NSlog.incl"

local fn EncodeStringAsBase64( stringToEncode as CFStringRef ) as CFStringRef
  CFStringRef encodedBase64Str = NULL
  CFDataRef dataToEncode = fn StringData( stringToEncode, NSUTF8StringEncoding )
  encodedBase64Str = fn DataBase64EncodedString( dataToEncode, 0 )
end fn = encodedBase64Str


local fn DecodeBase64String( base64String as CFStringRef ) as CFStringRef
  CFStringRef decodedString = NULL
  CFDataRef encodedData  = fn DataWithBase64EncodedString( base64String, NSDataBase64DecodingIgnoreUnknownCharacters )
  decodedString = fn StringWithData( encodedData, NSUTF8StringEncoding )
end fn = decodedString


CFStringRef originalString, encodedBase64String, decodedBase64String

originalString = @"This is a test string to be encoded as Base64 and then decoded."
NSLog( @"This is the original string:\n\t%@\n", originalString )

encodedBase64String = fn EncodeStringAsBase64( originalString )
NSLog( @"This is the original string encoded as Base84:\n\t%@\n", encodedBase64String )

decodedBase64String = fn DecodeBase64String( encodedBase64String )
NSLog( @"This is the Base64 string decoded:\n\t%@", decodedBase64String )

HandleEvents
Output:
This is the original string:
	This is a test string to be encoded as Base64 and then decoded.

This is the original string encoded as Base84:
	VGhpcyBpcyBhIHRlc3Qgc3RyaW5nIHRvIGJlIGVuY29kZWQgYXMgQmFzZTY0IGFuZCB0aGVuIGRlY29kZWQu

This is the Base64 string decoded:
	This is a test string to be encoded as Base64 and then decoded.


Go

As images can no longer be uploaded to RC, I've encoded and decoded a string rather than the Rosetta Code icon.

package main

import (
    "encoding/base64"
    "fmt"
)

func main() {
    msg := "Rosetta Code Base64 decode data task"
    fmt.Println("Original :", msg)
    encoded := base64.StdEncoding.EncodeToString([]byte(msg))
    fmt.Println("\nEncoded  :", encoded)
    decoded, err := base64.StdEncoding.DecodeString(encoded)
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println("\nDecoded  :", string(decoded))
}
Output:
Original : Rosetta Code Base64 decode data task

Encoded  : Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr

Decoded  : Rosetta Code Base64 decode data task

Groovy

Translation of: Java
import java.nio.charset.StandardCharsets

class Decode {
    static void main(String[] args) {
        String data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
        Base64.Decoder decoder = Base64.getDecoder()
        byte[] decoded = decoder.decode(data)
        String decodedStr = new String(decoded, StandardCharsets.UTF_8)
        System.out.println(decodedStr)
    }
}
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Haskell

Simple implementation that decodes an ASCII string.

--Decodes Base64 to ASCII
import qualified Data.Map.Strict as Map (Map, lookup, fromList)
import Data.Maybe (fromJust, listToMaybe, mapMaybe)
import Numeric (readInt, showIntAtBase)
import Data.Char (chr, digitToInt)
import Data.List.Split (chunksOf)

byteToASCII :: String -> String
byteToASCII = map chr . decoder

--generates list of bytes (represented by Int)
decoder :: String -> [Int]
decoder =
  map readBin .
  takeWhile (\x -> length x == 8) .
  chunksOf 8 . concatMap toBin . mapMaybe (`Map.lookup` table) . filter (/= '=')

--turns decimal into a list of char that represents a binary number
toBin :: Int -> String
toBin n = leftPad $ showIntAtBase 2 ("01" !!) n ""

--this adds all the zeros to the left that showIntAtBase omitted
leftPad :: String -> String
leftPad a = replicate (6 - length a) '0' ++ a

--turns list of '0' and '1' into list of 0 and 1
readBin :: String -> Int
readBin = fromJust . fmap fst . listToMaybe . readInt 2 (`elem` "01") digitToInt

--lookup list for the sextets
table :: Map.Map Char Int
table =
  Map.fromList $
  zip "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" [0 ..]

main :: IO ()
main =
  putStrLn $
  byteToASCII
    "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA=="
Output:
To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich


or in terms of Data.ByteString.Base64:

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString.Base64 as Base64 (decode, encode)
import qualified Data.ByteString.Char8 as B (putStrLn)

main :: IO ()
main = do
  B.putStrLn $
    Base64.encode
      "To err is human, but to really foul things up you need a computer.\n-- Paul R. Ehrlich"
  B.putStrLn "\n-->\n"
  either print B.putStrLn $
    Base64.decode
      "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA=="
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCi0tIFBhdWwgUi4gRWhybGljaA==

-->

To err is human, but to really foul things up you need a computer.
-- Paul R. Ehrlich

Haxe

class Main {
  static function main() {
    var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" + 
               "IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
    Sys.println('$data\n');
    var decoded = haxe.crypto.Base64.decode(data);
    Sys.println(decoded);
  }
}
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

J

using J's convert/misc/base64 script:

   require'convert/misc/base64'
   frombase64 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Alternative implementation based on that script:

BASE64=: (a.{~ ,(a.i.'Aa') +/i.26),'0123456789+/'

frombase64=: {{
  pad=. _2 >. (y i. '=') - #y
  pad }. a. {~ #. _8 [\ , (6#2) #: BASE64 i. y
}}

Java

Java offers the Base64 class, which includes both the Encoder and Decoder classes.
The implementation supports RFC 4648 and RFC 2045.

Similar to the encoding process, the usage is very simple, supply a byte array, and it will return an encoded byte array.

The class uses a static construct, so instead of instantiation via a constructor, you use one of the static methods.
In this case we'll use the Base64.getDecoder method to acquire our instance.

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Base64;
void decodeToFile(String path, byte[] bytes) throws IOException {
    try (FileOutputStream stream = new FileOutputStream(path)) {
        byte[] decoded = Base64.getDecoder().decode(bytes);
        stream.write(decoded, 0, decoded.length);
    }
}

The operation is successful, creating a 48 by 48-pixel, 32-bit color graphic, at 15,086 bytes.

An alternate demonstration

Translation of: Kotlin
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class Decode {
    public static void main(String[] args) {
        String data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
        Base64.Decoder decoder = Base64.getDecoder();
        byte[] decoded = decoder.decode(data);
        String decodedStr = new String(decoded, StandardCharsets.UTF_8);
        System.out.println(decodedStr);
    }
}
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

JavaScript

Browser

// define base64 data; in this case the data is the string: "Hello, world!"
const base64 = 'SGVsbG8sIHdvcmxkIQ==';
// atob is a built-in function.
console.log(atob(base64));

Node.js

// define base64 data; in this case the data is the string: "Hello, world!"
const base64 = Buffer.from('SGVsbG8sIHdvcmxkIQ==', 'base64');
// <Buffer>.toString() is a built-in method.
console.log(base64.toString());
Output:
Hello, world!

jq

Simply pipe the base64 string into:

   jq -rR base64d

Jsish

See Base64_encode_data#Jsish for base64.jsi.

/* Base64 decode, in Jsish */
var data = exec('jsish base64.jsi', {retAll:true}).data;  // or use File.read('stdin');
var icon = Util.base64(data, true);
File.write('rosetta-favicon.ico', icon);

Julia

Using an IOBuffer here, though not really needed to decode a string, shows how we could pipe a network stream or file though Julia's builtin Base64 decoder.

using Base64

io = IOBuffer()

iob64_decode = Base64DecodePipe(io)

write(io, "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo")

seekstart(io)

println(String(read(iob64_decode)))
Output:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Kotlin

Translation of: D
import java.util.Base64

fun main() {
    val data =
        "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
    val decoder = Base64.getDecoder()
    val decoded = decoder.decode(data)
    val decodedStr = String(decoded, Charsets.UTF_8)
    println(decodedStr)
}
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Lua

-- Start taken from https://stackoverflow.com/a/35303321
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding

-- decoding
function dec(data)
    data = string.gsub(data, '[^'..b..'=]', '')
    return (data:gsub('.', function(x)
        if (x == '=') then return '' end
        local r,f='',(b:find(x)-1)
        for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
        return r;
    end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
        if (#x ~= 8) then return '' end
        local c=0
        for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
            return string.char(c)
    end))
end
-- end of copy

local data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
print(data)
print()

local decoded = dec(data)
print(decoded)
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo

To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

M2000 Interpreter

Using a file and a Document object

Load.doc handle automatic UTF16LE UTF16BE UTF8 and ANSI. Also automatic find the type of new line (here is LF)

Tempname$ retuen a unique path+filename at temporary folder. The temporary file automatic deleted when the M2000 environment closed.

inp$={VG8gZXJyIGlzIGh1bWFuLCBidXQ
gdG8gcmVhbGx5IGZvdWwgdGhpbmdzI
HVwIHlvdSBuZWVkIGEgY29tcHV0ZXI
uCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
}
tmp$=tempname$
open tmp$ for wide output as #f  
	print #f, string$(inp$ as decode64);
close #f
document a$
load.doc a$, tmp$
report a$
clipboard a$
Without File

If we know the encoding and type of line feed we can do this:

inp$={VG8gZXJyIGlzIGh1bWFuLCBidXQ
gdG8gcmVhbGx5IGZvdWwgdGhpbmdzI
HVwIHlvdSBuZWVkIGEgY29tcHV0ZXI
uCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
}
// decode inp$ (is 8-bit ANSI coded using 0xA for paragraph end/new line)
a$=string$(inp$ as Decode64)
locale 1033
// convert ansi to utf16le using Locale 1033
a$=chr$(a$)  // convert to utf16LE
// expand LF to CRLF for M2000 console
a$=replace$(chr$(0xA), chr$(0XD)+chr$(0XA), a$)
// report handle cr and lf  using proportional spacing for text and auto word wrapping
report a$ 
// also Print channel #-2 handle cr and lf (using non proportional spacing)
print #-2, a$
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Mathematica/Wolfram Language

ImportString[
   "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo",
   "Base64"
]
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Nim

import base64

const Source = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="

echo Source.decode()
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

OCaml

We continue from the same toplevel session from the previous page:

# let plain = Base64.decode_exn enc;;
val plain : string =
  "\000\000\001\000\002\000\016\016\000\000\000\000\000\000h\005\000\000&\000"... (* string length 3638; truncated *)

Ol

(define base64-codes "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
(define kernel (alist->ff (map cons (string->bytes base64-codes) (iota (string-length base64-codes)))))

; returns n bits from input binary stream
(define (bits n hold)
   (let loop ((hold hold))
      (vector-apply hold (lambda (v i l)
         (cond
            ((null? l)
               (values (>> v (- i n)) #false))
            ((pair? l)
               (if (not (less? i n))
                  (values (>> v (- i n)) (vector (band v (- (<< 1 (- i n)) 1)) (- i n) l))
                  (loop (vector
                     (bor (<< v 6) (kernel (car l) 0))
                     (+ i 6)
                     (unless (eq? (car l) "=") (cdr l))))))
            (else
               (loop (vector v i (l)))))))))

; decoder.
(define (decode str)
   (print "decoding string '" str "':")
   (let loop ((hold [0 0 (str-iter str)]))
      (let*((bit hold (bits 8 hold)))
         (unless (zero? bit) (display (string bit)))
         (when hold
            (loop hold))))
   (print)(print))

; TESTING
(decode "SGVsbG8sIExpc3Ah")

(decode "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=")

(decode "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")
Output:
Hello, Lisp!

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.

Perl

The MIME::Base64 module is to be preferred, but this works too.

sub decode_base64 {
    my($d) = @_;
    $d =~ tr!A-Za-z0-9+/!!cd;
    $d =~ s/=+$//;
    $d =~ tr!A-Za-z0-9+/! -_!;
    my $r = '';
    while( $d =~ /(.{1,60})/gs ){
        my $len = chr(32 + length($1)*3/4);
        $r .= unpack("u", $len . $1 );
    }
    $r;
}

$data = <<EOD;
J1R3YXMgYnJpbGxpZywgYW5kIHRoZSBzbGl0aHkgdG92ZXMKRGlkIGd5cmUgYW5kIGdpbWJsZSBp
biB0aGUgd2FiZToKQWxsIG1pbXN5IHdlcmUgdGhlIGJvcm9nb3ZlcywKQW5kIHRoZSBtb21lIHJh
dGhzIG91dGdyYWJlLgo=
EOD

print decode_base64($data) . "\n";
Output:
'Twas brillig, and the slithy toves
Did gyre and gimble in the wabe:
All mimsy were the borogoves,
And the mome raths outgrabe.

Phix

with javascript_semantics
include builtins\base64.e
string s = "Rosetta Code Base64 decode data task"
string e = encode_base64(s)
?e
?decode_base64(e)
Output:
"Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr"
"Rosetta Code Base64 decode data task"

PHP

$encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw' .
           'IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
echo
    $encoded, PHP_EOL,
    base64_decode($encoded), PHP_EOL;
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

PicoLisp

(setq *Char64
   `'(chop
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) )
(de decode64 (S)
   (let S (chop S)
      (pack
         (make
            (while S
               (let
                  (A (dec (index (++ S) *Char64))
                     B (dec (index (++ S) *Char64))
                     C (dec (index (++ S) *Char64))
                     D (dec (index (++ S) *Char64)) )
                  (link
                     (char (| (>> -2 A) (>> 4 B))) )
                  (and
                     C
                     (link
                        (char
                           (| (>> -4 (& B 15)) (>> 2 C)) ) )
                     D
                     (link
                        (char (| (>> -6 (& C 3)) D)) ) ) ) ) ) ) ) )
(prinl (decode64 "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"))
Output:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Pike

By necessity this also implements all of the Base64 encode task to avoid a humongous amount of icon data hardcoded in the program.

string icon = Protocols.HTTP.get_url_data("http://rosettacode.org/favicon.ico");
string encoded = MIME.encode_base64(icon);
Stdio.write_file("favicon.ico", MIME.decode_base64(encoded));

Prolog

In SWI-Prolog base64 is a built in predicate. https://www.swi-prolog.org/pldoc/doc_for?object=base64%3Abase64/2

This predicate is reversable and can encode or decode.

Output:
?- Encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=', 
base64(Plain, Encoded).

Plain = 'To err is human, but to really foul things up you need a computer.\n    -- Paul R. Ehrlich'.

PureBasic

b64cd$ = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
         "IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="

*p_buf = AllocateMemory(1024)
Base64Decoder(b64cd$, *p_buf, 1024)
OpenConsole("") : PrintN(PeekS(*p_buf, -1, #PB_UTF8))
Input()
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Python

import base64
data = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
print(base64.b64decode(data).decode('utf-8'))
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

QB64

Option _Explicit

Dim As String udata, decoded
udata = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"

decoded = decode(udata)

Print udata
Print decoded

Function findIndex& (value As _Unsigned _Byte)
    If Asc("A") <= value And value <= Asc("Z") Then
        findIndex = value - Asc("A")
        Exit Function
    End If
    If Asc("a") <= value And value <= Asc("z") Then
        findIndex = value - Asc("a") + 26
        Exit Function
    End If
    If Asc("0") <= value And value <= Asc("9") Then
        findIndex = value - Asc("0") + 52
        Exit Function
    End If
    If value = Asc("+") Then
        findIndex = 62
        Exit Function
    End If
    If value = Asc("/") Then
        findIndex = 63
        Exit Function
    End If
    findIndex = -1
End Function

Function encode$ (source As String)
    Dim As String Base64: Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
    Dim As _Unsigned _Integer64 length: length = Len(source)
    Dim As _Unsigned _Integer64 it, strend
    Dim As Long acc
    Dim As String sink
    strend = length
    While it <> strend
        Dim As _Unsigned _Byte b1, b2, b3, b4
        it = it + 1
        b1 = Asc(Mid$(source, it, 1))
        sink = sink + Mid$(Base64, _SHR(b1, 2), 1)
        acc = _SHL(b1 And &H3, 4)
        If it <> strend Then
            it = it + 1
            b2 = Asc(Mid$(source, it, 1))
            acc = acc Or _SHR(b2, 4)
            sink = sink + Mid$(Base64, acc, 1)
            acc = _SHL(b2 And &HF, 2)
            If it <> strend Then
                it = it + 1
                b3 = Asc(Mid$(source, it, 1))
                acc = acc Or _SHR(b3, 6)
                sink = sink + Mid$(Base64, acc, 1)
                sink = sink + Mid$(Base64, b3 And &H3F, 1)
            Else
                sink = sink + Mid$(Base64, acc, 1)
                sink = sink + "="
            End If
        Else
            sink = sink + Mid$(Base64, acc, 1)
            sink = sink + "="
            sink = sink + "="
        End If
    Wend
    encode = sink
End Function

Function decode$ (source As String)
    Dim As _Unsigned _Integer64 length: length = Len(source)
    Dim As _Unsigned _Integer64 it, strend
    Dim As Long acc
    Dim As String sink
    strend = length
    While it <> strend
        Dim As _Unsigned _Byte b1, b2, b3, b4
        it = it + 1
        b1 = Asc(Mid$(source, it, 1))
        it = it + 1
        b2 = Asc(Mid$(source, it, 1))
        it = it + 1
        b3 = Asc(Mid$(source, it, 1))
        it = it + 1
        b4 = Asc(Mid$(source, it, 1))
        Dim As Long i1, i2
        i1 = findIndex(b1)
        i2 = findIndex(b2)
        acc = _SHL(i1, 2)
        acc = acc Or _SHR(i2, 4)
        sink = sink + Chr$(acc)
        If b3 <> Asc("=") Then
            Dim As Long i3
            i3 = findIndex(b3)
            acc = _SHL(i2 And &HF, 4)
            acc = acc Or _SHR(i3, 2)
            sink = sink + Chr$(acc)
            If b4 <> Asc("=") Then
                Dim As Long i4
                i4 = findIndex(b4)
                acc = _SHL(i3 And &H3, 6)
                acc = acc Or i4
                sink = sink + Chr$(acc)
            End If
        End If
    Wend
    decode = sink
End Function
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

R

Using base64enc

Works with: R version 4.1.0
Library: base64enc
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo" |>
  base64enc::base64decode() |>
  rawToChar() |>
  cat()
Output:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Racket

#lang racket
(require net/url net/base64)

;; decode a string
(displayln (base64-decode #"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="))

;; (encode and) decode the favicon
(displayln (base64-decode (base64-encode (call/input-url (string->url "https://rosettacode.org/favicon.ico")
                                              get-pure-port port->bytes))))
Output:

(string output only)

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Raku

(formerly Perl 6)

Works with: Rakudo version 2018.11
my $e64 = '
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
';

my @base64map = flat 'A' .. 'Z', 'a' .. 'z', ^10, '+', '/';
my %base64 is default(0) = @base64map.pairs.invert;

sub base64-decode-slow ($enc) {
    my $buf = Buf.new;
    for $enc.subst(/\s/, '', :g).comb(4) -> $chunck {
        $buf.append: |(sprintf "%06d%06d%06d%06d", |$chunck.comb.map:
            {%base64{$_}.base(2)}).comb(8).map: {:2($_)};
    }
    $buf
}

say 'Slow:';
say base64-decode-slow($e64).decode('utf8');


# Of course, the above routine is slow and is only for demonstration purposes.
# For real code you should use a module, which is MUCH faster and heavily tested.
say "\nFast:";
use Base64::Native;
say base64-decode($e64).decode('utf8');
Output:
Slow:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Fast:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Red

Red [Source: https://github.com/vazub/rosetta-red]

print to-string debase "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Ring

#======================================#
#  Sample: Base64 decode data 
#  Author: Gal Zsolt, Mansour Ayouni
#======================================#

load "guilib.ring"

oQByteArray = new QByteArray()
oQByteArray.append("Rosetta Code Base64 decode data task")
oba = oQByteArray.toBase64().data()
see oba + nl

oQByteArray = new QByteArray()
oQByteArray.append(oba)
see oQByteArray.fromBase64(oQByteArray).data()
Output:
Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr
Rosetta Code Base64 decode data task

RPL

Works with: RPL version HP-49C
« "" DUP DUP2 → s a b c d
  « "" 
    1 s SIZE FOR j 
       0 3 FOR k      
          "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 
          s j k + DUP SUB POS
       NEXT 
       4 →LIST 1 - { a b c d } STO 
       a 4 * b 16 / IP + CHR +
       IF c -1 ≠ THEN b 16 MOD 16 * c 4 / IP + CHR + END
       IF d -1 ≠ THEN c 4 MOD 64 * d + CHR + END 
   4 STEP
 » » 'B64→' STO
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=" B64→
Output:
 1: "To err is human, but to really foul things up you need a computer.
   -- Paul R. Ehrlich"

Ruby

require 'base64'

raku_example ='
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
'
puts Base64.decode64 raku_example
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Rust

use std::str;

const INPUT: &str = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
const UPPERCASE_OFFSET: i8 = -65;
const LOWERCASE_OFFSET: i8 = 26 - 97;
const NUM_OFFSET: i8 = 52 - 48;

fn main() {
    println!("Input: {}", INPUT);

    let result = INPUT.chars()
        .filter(|&ch| ch != '=')                                //Filter '=' chars
        .map(|ch| {                                             //Map char values using Base64 Characters Table
            let ascii = ch as i8;                           
            let convert = match ch {
                '0' ... '9' => ascii + NUM_OFFSET,
                'a' ... 'z' => ascii + LOWERCASE_OFFSET,
                'A' ... 'Z' => ascii + UPPERCASE_OFFSET,
                '+' => 62,
                '/' => 63,
                _ => panic!("Not a valid base64 encoded string")
            };
            format!("{:#08b}", convert)[2..].to_string()        //convert indices to binary format and remove the two first digits
        })
        .collect::<String>()                                    //concatenate the resulting binary values
        .chars()
        .collect::<Vec<char>>()
        .chunks(8)                                              //split into 8 character chunks
        .map(|chunk| {
            let num_str = chunk.iter().collect::<String>();
            usize::from_str_radix(&num_str, 2).unwrap() as u8   //convert the binary string into its u8 value
        })
        .collect::<Vec<_>>();

    let result = str::from_utf8(&result).unwrap();              //convert into UTF-8 string

    println!("Output: {}", result);
}
Output:
Input: VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo
Output: To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

Scala

Output:

Best seen in running your browser either by ScalaFiddle (ES aka JavaScript, non JVM) or Scastie (remote JVM).

import java.util.Base64

object Base64Decode extends App {

  def text2BinaryDecoding(encoded: String): String = {
    val decoded = Base64.getDecoder.decode(encoded)
    new String(decoded, "UTF-8")
  }

  def data =
    "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="

  println(text2BinaryDecoding(data))
}

Seed7

The Seed7 library encoding.s7i defines the functions toBase64 and fromBase64.

$ include "seed7_05.s7i";
  include "gethttp.s7i";
  include "encoding.s7i";

const proc: main is func
  local
    var string: original is "";
    var string: encoded is "";
  begin
    original := getHttp("rosettacode.org/favicon.ico");
    encoded := toBase64(original);
    writeln("Is the Rosetta Code icon the same (byte for byte) encoded then decoded: " <&
            fromBase64(encoded) = original);
  end func;
Output:
Is the Rosetta Code icon the same (byte for byte) encoded then decoded: TRUE

SenseTalk

put base64Decode ("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuIC0tUGF1bCBSLkVocmxpY2g=")

Output:

To err is human, but to really foul things up you need a computer. --Paul R.Ehrlich

Sidef

var data = <<'EOT'
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
EOT

say data.decode_base64
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Smalltalk

Works with: Smalltalk/X
data := '
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
'.

data base64Decoded asString printCR.
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Standard ML

val debase64 = fn input =>
let

 infix 2 Worb
 infix 2 Wandb
 fun (p Worb q )  =  Word.orb  (p,q);
 fun (p Wandb q ) =  Word.andb (p,q);

fun decode #"/" =  0wx3F
  | decode #"+" =  0wx3E
  | decode c    =  if Char.isDigit c then Word.fromInt (ord c) +  0wx04
              else if Char.isLower c then Word.fromInt (ord c) - 0wx047
              else if Char.isUpper c then Word.fromInt (ord c) - 0wx041
              else 0wx00 ;

fun convert (a::b::c::d::_) =
         let
            val w = Word.<< (a,0wx12) Worb Word.<< (b,0wx0c) Worb Word.<< (c,0wx06) Worb d
         in
            [Word.>> (w,0wx10), Word.>> ((w Wandb 0wx00ff00),0wx08) , w Wandb 0wx0000ff ]
         end
  | convert _ = [] ;

fun decodeLst []    = []
  | decodeLst ilist = ( convert o  map decode )( List.take (ilist,4) ) @  decodeLst (List.drop (ilist,4))
  
in

  String.implode ( List.map (chr o Word.toInt) ( decodeLst (String.explode input ))  )

end                                                                 handle Subscript  => "Invalid code\n" ;

call

val input = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=";
print (debase64 input) ;

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich 

Swift

import Foundation

let input = """
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
"""

if let decoded = Data(base64Encoded: input),
let str = String(data: decoded, encoding: .utf8) {
	print( str )
}
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Tcl

package require tcl 8.6
set data VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

puts [binary decode base64 $data]
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

Visual Basic .NET

Translation of: D
Module Module1

    Sub Main()
        Dim data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
        Console.WriteLine(data)
        Console.WriteLine()

        Dim decoded = Text.Encoding.ASCII.GetString(Convert.FromBase64String(data))
        Console.WriteLine(decoded)
    End Sub

End Module
Output:
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=

To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

V (Vlang)

import encoding.base64

fn main() {
    msg := "Rosetta Code Base64 decode data task"
    println("Original : $msg")
    encoded := base64.encode_str(msg)
    println("\nEncoded  : $encoded")
    decoded := base64.decode_str(encoded)
    println("\nDecoded  : $decoded")
}
Output:
Original : Rosetta Code Base64 decode data task

Encoded  : Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr

Decoded  : Rosetta Code Base64 decode data task

Wren

Library: Wren-fmt
Library: Wren-str

From first principles using string manipulation. Quick enough here.

import "io" for Stdout
import "./fmt" for Conv, Fmt
import "./str" for Str

var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

var decode = Fn.new { |s|
   if (s == "") return s
   var d = ""
   for (b in s) {
       var ix = alpha.indexOf(b)
       if (ix >= 0) d = d + Fmt.swrite("$06b", ix)
   }
   if (s.endsWith("==")) {
        d = d[0..-5]
   } else if (s.endsWith("=")){
        d = d[0..-3]
   }
   var i = 0
   while (i < d.count) {
        var ch = String.fromByte(Conv.atoi(d[i..i+7], 2))
        System.write(ch)
        i = i + 8
   }
   Stdout.flush()
}

var s = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
for (chunk in Str.chunks(s, 4)) decode.call(chunk)
System.print()
Output:
To err is human, but to really foul things up you need a computer.
    -- Paul R. Ehrlich

XPL0

func Decode(Ch);
int  Ch;
[if Ch>=^A & Ch<=^Z then return Ch - ^A;
 if Ch>=^a & Ch<=^z then return Ch - ^a + 26;
 if Ch>=^0 & Ch<=^9 then return Ch - ^0 + 52;
 if Ch = ^+ then return 62;
 if Ch = ^/ then return 63;
return -1;
];

char Str;
int  Count, N, Ch, Code, Acc;
[Str:= 
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEg
 Y29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo ";
loop    [Count:= 0;
        for N:= 1 to 4 do                       \read in four 6-bit chars
                [repeat Ch:= Str(0);            \strip out whitespace
                        Str:= Str+1;
                        if Ch = $A0 then quit;  \terminating space
                until   Ch > $20;
                Code:= Decode(Ch);
                Acc:= Acc<<6;
                if Code >= 0 then               \don't count possible "="
                        [Acc:= Acc + Code;
                        Count:= Count+1;
                        ];
                ];
        ChOut(0, Acc>>16);                      \write out three 8-bit chars
        if Count >= 3 then ChOut(0, Acc>>8);
        if Count >= 4 then ChOut(0, Acc);
        ];
]
Output:
To err is human, but to really foul things up you need a computer.
    --Paul R.Ehrlich

zkl

Using shared libraries for cURL and message hashing:

var [const] MsgHash=Import("zklMsgHash"), Curl=Import("zklCurl");
 
icon:=Curl().get("http://rosettacode.org/favicon.ico"); //-->(Data(4,331),693,0)
icon=icon[0][icon[1],*];	// remove header
iconEncoded:=MsgHash.base64encode(icon);
iconDecoded:=MsgHash.base64decode(iconEncoded);
File("rosettaCodeIcon.ico","wb").write(iconDecoded); # eyeball checking says good
println("Is the Rosetta Code icon the same (byte for byte) encoded then decoded: ",
   icon==iconDecoded);
Output:
Is the Rosetta Code icon the same (byte for byte) encoded then decoded: True
Text based test:
msg,b64 := "Rosetta Code Base64 decode data task", MsgHash.base64encode(msg);
println("Original: %s\nEncoded:  %s\nBytes:    %s\nDecoded:  %s"
   .fmt(msg, b64.text, b64.bytes().apply("toString",16).concat(","),
        MsgHash.base64decode(b64).text));
Original: Rosetta Code Base64 decode data task
Encoded:  Um9zZXR0YSBDb2RlIEJhc2U2NCBkZWNvZGUgZGF0YSB0YXNr

Bytes:    55,6d,39,7a,5a,58,52,30,59,53,42,44,62,32,52,6c,49,45,4a,68,63,32,55,32,4e,43,42,6b,5a,57,4e,76,5a,47,55,67,5a,47,46,30,59,53,42,30,59,58,4e,72,a
Decoded:  Rosetta Code Base64 decode data task