Code Monkey home page Code Monkey logo

mime-base64's Introduction

Actions Status

NAME

MIME::Base64 - Encoding and decoding Base64 ASCII strings

SYNOPSIS

use MIME::Base64;

my $encoded = MIME::Base64.encode-str("xyzzy‽", :eol("\x0D\x0A"));
my $decoded = MIME::Base64.decode-str($encoded);

or

use MIME::Base64;

my $encoded     = MIME::Base64.encode($blob, );
my $decoded-buf = MIME::Base64.decode($encoded);

DESCRIPTION

Implements encoding and decoding to and from base64.

METHODS

encode(Blob $data, :$oneline, :$eol = "\n" --> Str:D)

Encodeѕ binary data $data in base64 format.

By default, the output is wrapped every 76 characters. If :$oneline is set, wrapping will be disabled. Also optionally takes a :eol named argument to indicate the type of line-ending to be used. Defaults to "\n".

decode(Str:D $encoded --> Str:D)

Decodes base64 encoded data into a binary buffer.

encode-str(Str:D $string, :$oneline, :$eol = "\n" --> Str:D)`

Encodes $string into base64, assuming utf8 encoding. By default, the output is wrapped every 76 characters. If :$oneline is set, wrapping will be disabled. Also optionally takes a :eol named argument to indicate the type of line-ending to be used. Defaults to "\n".

decode-str(Str:D $encoded --> Str:D)`

Decodes $encoded into a string, assuming utf8 encoding.

COMPATIBILITY METHODS

encode_base64(Str:D $string --> Str:D)

Same as .encode-str($string.

decode_base64(Str:D $encoded --> Str:D)

Calls .decode-str($encoded)

AUTHOR

Originally written by Adrian White. Maintained by many other people over the years. Now being maintained as a Raku community module.

COPYRIGHT AND LICENSE

Copyright 2010 - 2011 Adrian White

Copyright 2012 - 2022 Raku Community

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.

mime-base64's People

Contributors

fayland avatar froggs avatar glassflag avatar jdv avatar jonathanstowe avatar lizmat avatar moritz avatar retupmoca avatar ronaldxs avatar snarkyboojum avatar tokuhirom avatar zakame avatar zoffixznet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mime-base64's Issues

Test failure on parrot

With rakudo-parrot, "make test" produces this output:

t/binary-and-long-line.t .. ===SORRY!=== Error while compiling t/binary-and-long-line.t
Unrecognized character name LEFT CORNER BRACKET
at t/binary-and-long-line.t:25
------> unicode-chars = "\c[ LEFT CORNER BRACKET⏏ ]\c[ SNOWMAN ]\c[
t/binary-and-long-line.t .. No subtests run 

Incorrect line breaks.

RFC 2045 defines CRLF as line break sequence - https://tools.ietf.org/html/rfc2045#section-2.1 .

So when it says in "Base64 Content-Transfer-Encoding" section that

The encoded output stream must be represented in lines of no more than 76 characters each.
it implies CRLF as line break to use.

Or maybe line break sequence can be added as additional param to encode?
(decode can be left as-is should ignore all line breaks and characters outside base 64 alphabet anyway).

I'm creating this issue mostly because when Base64 line break is inconsistent with rest of the email (for example created with Email::MIME that uses CRLF by default) it causes weird edge cases for DKIM canonicalization algorithms described in http://www.ietf.org/rfc/rfc6376.txt.

Test failure using panda

==> Fetching MIME::Base64
==> Building MIME::Base64
==> Testing MIME::Base64
This type does not support elems
  in any  at gen/moar/m-Metamodel.nqp line 1723
  in method decode at /path/to/.panda-work/1457223424_1/lib/MIME/Base64/Perl.pm6 line 103
  in method decode-str at /path/to/.panda-work/1457223424_1/lib/MIME/Base64.pm6 line 10
  in method decode_base64 at /path/to/.panda-work/1457223424_1/lib/MIME/Base64.pm6 line 19
  in block <unit> at t/basic.t line 14

# Looks like you planned 18 tests, but ran 1
t/basic.t ................. 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 17/18 subtests 
t/binary-and-long-line.t .. ok
t/oneline.t ............... ok
This type does not support elems
  in any  at gen/moar/m-Metamodel.nqp line 1723
  in method decode at /path/to/.panda-work/1457223424_1/lib/MIME/Base64/Perl.pm6 line 103
  in method decode-str at /path/to/.panda-work/1457223424_1/lib/MIME/Base64.pm6 line 10
  in block <unit> at t/rfc4648-test-vector.t line 23

# Looks like you planned 16 tests, but ran 7
t/rfc4648-test-vector.t ... 
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 9/16 subtests 

Test Summary Report
-------------------
t/basic.t               (Wstat: 65280 Tests: 1 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 18 tests but ran 1.
t/rfc4648-test-vector.t (Wstat: 65280 Tests: 7 Failed: 0)
  Non-zero exit status: 255
  Parse errors: Bad plan.  You planned 16 tests but ran 7.
Files=4, Tests=21,  4 wallclock secs ( 0.02 usr  0.00 sys +  3.42 cusr  0.18 csys =  3.62 CPU)
Result: FAIL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.