Base64 decode data: Difference between revisions

Content added Content deleted
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 8: Line 8:


=={{header|Action!}}==
=={{header|Action!}}==
<syntaxhighlight lang=Action!>BYTE FUNC FindIndex(BYTE b)
<syntaxhighlight lang="action!">BYTE FUNC FindIndex(BYTE b)
IF b>='A AND b<='Z THEN
IF b>='A AND b<='Z THEN
RETURN (b-'A)
RETURN (b-'A)
Line 95: Line 95:
=={{header|Ada}}==
=={{header|Ada}}==
{{libheader|AWS}}
{{libheader|AWS}}
<syntaxhighlight lang=Ada>with Ada.Text_IO;
<syntaxhighlight lang="ada">with Ada.Text_IO;


with AWS.Translator;
with AWS.Translator;
Line 118: Line 118:
=={{header|Arturo}}==
=={{header|Arturo}}==


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


print decode text</syntaxhighlight>
print decode text</syntaxhighlight>
Line 129: Line 129:
=={{header|BaCon}}==
=={{header|BaCon}}==
Using the result from the [[Base64 encode data]] task as requested, but the result is abbreviated in the code below.
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="
<syntaxhighlight lang="bacon">data$ = "AAABAAIAEBAAAAAAAABoBQAAJgAAACAgAAAAAAAAqAgAAI4FAAAoAAAAE.......QAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAE="
ico$ = B64DEC$(data$)
ico$ = B64DEC$(data$)
BSAVE ico$ TO "favicon.ico" SIZE LEN(ico$)</syntaxhighlight>
BSAVE ico$ TO "favicon.ico" SIZE LEN(ico$)</syntaxhighlight>
Line 135: Line 135:
=={{header|Bash}}==
=={{header|Bash}}==
{{trans|Bash}}
{{trans|Bash}}
<syntaxhighlight 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 193: Line 193:
=={{header|C}}==
=={{header|C}}==
{{trans|C++}}
{{trans|C++}}
<syntaxhighlight lang=c>#include <stdio.h>
<syntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>


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


Line 303: Line 303:
=={{header|C++}}==
=={{header|C++}}==
{{Works with|C++14}}
{{Works with|C++14}}
<syntaxhighlight lang=cpp>#include <algorithm>
<syntaxhighlight lang="cpp">#include <algorithm>
#include <iostream>
#include <iostream>
#include <string>
#include <string>
Line 435: Line 435:
=={{header|Clojure}}==
=={{header|Clojure}}==


<syntaxhighlight 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)))


Line 449: Line 449:
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.


<syntaxhighlight 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 477: Line 477:


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


encoded_string = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
encoded_string = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
Line 491: Line 491:
=={{header|D}}==
=={{header|D}}==
{{trans|Raku}}
{{trans|Raku}}
<syntaxhighlight lang=d>import std.base64;
<syntaxhighlight lang="d">import std.base64;
import std.stdio;
import std.stdio;


Line 509: Line 509:


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


void main() {
void main() {
Line 524: Line 524:


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


{$APPTYPE CONSOLE}
{$APPTYPE CONSOLE}
Line 549: Line 549:
=={{header|F_Sharp|F#}}==
=={{header|F_Sharp|F#}}==
===Standard Library===
===Standard Library===
<syntaxhighlight lang=fsharp>
<syntaxhighlight lang="fsharp">
open System
open System
open System.IO
open System.IO
Line 563: Line 563:


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


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


"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo"
Line 613: Line 613:
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
<syntaxhighlight lang=forth>variable bitsbuff
<syntaxhighlight lang="forth">variable bitsbuff


: char>6bits ( c -- u )
: char>6bits ( c -- u )
Line 670: Line 670:


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<syntaxhighlight lang=freebasic>Dim Shared As String B64
<syntaxhighlight lang="freebasic">Dim Shared As String B64
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
"abcdefghijklmnopqrstuvwxyz" & _
"abcdefghijklmnopqrstuvwxyz" & _
Line 714: Line 714:
=={{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.
<syntaxhighlight lang=go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 745: Line 745:
=={{header|Groovy}}==
=={{header|Groovy}}==
{{trans|Java}}
{{trans|Java}}
<syntaxhighlight lang=groovy>import java.nio.charset.StandardCharsets
<syntaxhighlight lang="groovy">import java.nio.charset.StandardCharsets


class Decode {
class Decode {
Line 762: Line 762:
=={{header|Haskell}}==
=={{header|Haskell}}==
Simple implementation that decodes an ASCII string.
Simple implementation that decodes an ASCII string.
<syntaxhighlight 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 810: Line 810:
or in terms of Data.ByteString.Base64:
or in terms of Data.ByteString.Base64:


<syntaxhighlight 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 833: Line 833:


=={{header|Haxe}}==
=={{header|Haxe}}==
<syntaxhighlight lang=haxe>class Main {
<syntaxhighlight lang="haxe">class Main {
static function main() {
static function main() {
var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
var data = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw" +
Line 850: Line 850:
using J's [https://github.com/jsoftware/convert_misc/blob/master/base64.ijs convert/misc/base64] script:
using J's [https://github.com/jsoftware/convert_misc/blob/master/base64.ijs convert/misc/base64] script:


<syntaxhighlight lang=J> require'convert/misc/base64'
<syntaxhighlight lang="j"> require'convert/misc/base64'
frombase64 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
frombase64 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
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 857: Line 857:
Alternative implementation based on that script:
Alternative implementation based on that script:


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


Line 868: Line 868:
=={{header|Java}}==
=={{header|Java}}==
{{trans|Kotlin}}
{{trans|Kotlin}}
<syntaxhighlight lang=java>import java.nio.charset.StandardCharsets;
<syntaxhighlight lang="java">import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Base64;


Line 886: Line 886:
=={{header|JavaScript}}==
=={{header|JavaScript}}==
=== Browser ===
=== Browser ===
<syntaxhighlight lang=javascript>// define base64 data; in this case the data is the string: "Hello, world!"
<syntaxhighlight lang="javascript">// define base64 data; in this case the data is the string: "Hello, world!"
const base64 = 'SGVsbG8sIHdvcmxkIQ==';
const base64 = 'SGVsbG8sIHdvcmxkIQ==';
// atob is a built-in function.
// atob is a built-in function.
console.log(atob(base64));</syntaxhighlight>
console.log(atob(base64));</syntaxhighlight>
=== Node.js ===
=== Node.js ===
<syntaxhighlight lang=javascript>// define base64 data; in this case the data is the string: "Hello, world!"
<syntaxhighlight lang="javascript">// define base64 data; in this case the data is the string: "Hello, world!"
const base64 = Buffer.from('SGVsbG8sIHdvcmxkIQ==', 'base64');
const base64 = Buffer.from('SGVsbG8sIHdvcmxkIQ==', 'base64');
// <Buffer>.toString() is a built-in method.
// <Buffer>.toString() is a built-in method.
Line 907: Line 907:
See [[Base64_encode_data#Jsish]] for ''base64.jsi''.
See [[Base64_encode_data#Jsish]] for ''base64.jsi''.


<syntaxhighlight 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);
Line 914: Line 914:
=={{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.
<syntaxhighlight lang=julia>using Base64
<syntaxhighlight lang="julia">using Base64


io = IOBuffer()
io = IOBuffer()
Line 933: Line 933:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|D}}
{{trans|D}}
<syntaxhighlight lang=scala>import java.util.Base64
<syntaxhighlight lang="scala">import java.util.Base64


fun main() {
fun main() {
Line 948: Line 948:


=={{header|Lua}}==
=={{header|Lua}}==
<syntaxhighlight 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 981: Line 981:


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang=Mathematica>ImportString[
<syntaxhighlight lang="mathematica">ImportString[
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo",
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo",
"Base64"
"Base64"
Line 990: Line 990:


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


const Source = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
const Source = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g="
Line 1,009: Line 1,009:


=={{header|Ol}}==
=={{header|Ol}}==
<syntaxhighlight 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 1,059: Line 1,059:
=={{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.
<syntaxhighlight 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 1,086: Line 1,086:


=={{header|Phix}}==
=={{header|Phix}}==
<!--<syntaxhighlight lang=Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<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>
<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>
Line 1,101: Line 1,101:


=={{header|PHP}}==
=={{header|PHP}}==
<syntaxhighlight lang=PHP>$encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw' .
<syntaxhighlight lang="php">$encoded = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVw' .
'IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
'IHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=';
echo
echo
Line 1,112: Line 1,112:


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<syntaxhighlight lang=PicoLisp>(setq *Char64
<syntaxhighlight lang="picolisp">(setq *Char64
`'(chop
`'(chop
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) )
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) )
Line 1,145: Line 1,145:
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>
<syntaxhighlight 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);
Line 1,164: Line 1,164:


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


Line 1,176: Line 1,176:


=={{header|Python}}==
=={{header|Python}}==
<syntaxhighlight lang=Python>
<syntaxhighlight lang="python">
import base64
import base64
data = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
data = 'VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g='
Line 1,187: Line 1,187:
</pre>
</pre>
=={{header|QB64}}==
=={{header|QB64}}==
<syntaxhighlight lang=vb>Option _Explicit
<syntaxhighlight lang="vb">Option _Explicit


Dim As String udata, decoded
Dim As String udata, decoded
Line 1,309: Line 1,309:
{{works with|R|4.1.0}}
{{works with|R|4.1.0}}
{{libheader|base64enc}}
{{libheader|base64enc}}
<syntaxhighlight lang=rsplus>
<syntaxhighlight lang="rsplus">
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo" |>
"VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo" |>
base64enc::base64decode() |>
base64enc::base64decode() |>
Line 1,324: Line 1,324:
{{works with|Rakudo|2018.11}}
{{works with|Rakudo|2018.11}}


<syntaxhighlight lang=raku line>my $e64 = '
<syntaxhighlight lang="raku" line>my $e64 = '
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 1,360: Line 1,360:


=={{header|Red}}==
=={{header|Red}}==
<syntaxhighlight 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"
Line 1,371: Line 1,371:


=={{header|Ring}}==
=={{header|Ring}}==
<syntaxhighlight lang=ring>
<syntaxhighlight lang="ring">
#======================================#
#======================================#
# Sample: Base64 decode data
# Sample: Base64 decode data
Line 1,395: Line 1,395:


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


raku_example ='
raku_example ='
Line 1,409: Line 1,409:


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


const INPUT: &str = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
const INPUT: &str = "VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLVBhdWwgUi5FaHJsaWNo";
Line 1,456: Line 1,456:
=={{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)].
<syntaxhighlight lang=Scala>import java.util.Base64
<syntaxhighlight lang="scala">import java.util.Base64


object Base64Decode extends App {
object Base64Decode extends App {
Line 1,476: Line 1,476:
[http://seed7.sourceforge.net/libraries/encoding.htm#fromBase64(in_string) fromBase64].
[http://seed7.sourceforge.net/libraries/encoding.htm#fromBase64(in_string) fromBase64].


<syntaxhighlight 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,495: Line 1,495:


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


put base64Decode ("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuIC0tUGF1bCBSLkVocmxpY2g=")
put base64Decode ("VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuIC0tUGF1bCBSLkVocmxpY2g=")
Line 1,502: Line 1,502:


Output:
Output:
<syntaxhighlight lang=sensetalk>To err is human, but to really foul things up you need a computer. --Paul R.Ehrlich</syntaxhighlight>
<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}}==
<syntaxhighlight lang=ruby>var data = <<'EOT'
<syntaxhighlight lang="ruby">var data = <<'EOT'
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 1,519: Line 1,519:
=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<syntaxhighlight lang=smalltalk>data := '
<syntaxhighlight lang="smalltalk">data := '
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY2
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
9tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
Line 1,530: Line 1,530:


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


Line 1,569: Line 1,569:
-- Paul R. Ehrlich </pre>
-- Paul R. Ehrlich </pre>
=={{header|Tcl}}==
=={{header|Tcl}}==
<syntaxhighlight lang=tcl>package require tcl 8.6
<syntaxhighlight lang="tcl">package require tcl 8.6
set data VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=
set data VG8gZXJyIGlzIGh1bWFuLCBidXQgdG8gcmVhbGx5IGZvdWwgdGhpbmdzIHVwIHlvdSBuZWVkIGEgY29tcHV0ZXIuCiAgICAtLSBQYXVsIFIuIEVocmxpY2g=


Line 1,581: Line 1,581:
=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==
{{trans|D}}
{{trans|D}}
<syntaxhighlight lang=vbnet>Module Module1
<syntaxhighlight lang="vbnet">Module Module1


Sub Main()
Sub Main()
Line 1,600: Line 1,600:


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


fn main() {
fn main() {
Line 1,624: Line 1,624:
{{libheader|Wren-str}}
{{libheader|Wren-str}}
From first principles using string manipulation. Quick enough here.
From first principles using string manipulation. Quick enough here.
<syntaxhighlight lang=ecmascript>import "io" for Stdout
<syntaxhighlight lang="ecmascript">import "io" for Stdout
import "/fmt" for Conv, Fmt
import "/fmt" for Conv, Fmt
import "/str" for Str
import "/str" for Str
Line 1,663: Line 1,663:
=={{header|zkl}}==
=={{header|zkl}}==
Using shared libraries for cURL and message hashing:
Using shared libraries for cURL and message hashing:
<syntaxhighlight 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,677: Line 1,677:
</pre>
</pre>
{{out|Text based test}}
{{out|Text based test}}
<syntaxhighlight 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(","),