Base64::Native

Fast Base 64 encoding and decoding (eager)

Base64-Native-p6

Faster than average Base 64 encoding and decoding.

Synopsis

use Base64::Native;

## Encoding ##

my buf8 $buf = base64-encode("Lorem ipsum");
say $buf;
# Buf[uint8]:0x<54 47 39 79 5a 57 30 67 61 58 42 7a 64 57 30 3d>
say base64-encode("Lorem ipsum", :str);
# TG9yZW0gaXBzdW0=

## Decoding ##

say base64-decode($buf);
# Buf[uint8]:0x<4c 6f 72 65 6d 20 69 70 73 75 6d>
say base64-decode("TG9yZW0gaXBzdW0=").decode;
# "Lorem ipsum"

URI Encoding

By default, codes 63 and 64 are encoded to '+' and '/'. The :uri option maps these to '-' and '_'.

use Base64::Native;

my $data = base64-decode("AB+/");
say base64-encode( $data, :str );
# AB+/
say base64-encode( $data, :str, :uri );
# AB-_

URI Decoding

URI and standard (MIME) mappings are both recognized by the base64-decode routine.

use Base64::Native;

say base64-decode("AB+/");
# Buf[uint8]:0x<00 1f bf>
say base64-decode("AB-_");
# Buf[uint8]:0x<00 1f bf>

Base64::Native v0.0.8

Fast Base 64 encoding and decoding (eager)

Authors

  • David Warring

License

Artistic-2.0

Dependencies

LibraryMake

Test Dependencies

Provides

  • Base64::Native

Documentation

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.