sub decode-base64(Str:D $str, Bool:D :$bin = False) { my @alpha = flat 'A'..'Z','a'..'z','0'..'9', '+', '/'; my %encodings = @alpha.kv.hash.antipairs; my $ords := $str.comb(/@alpha/).rotor(4, :partial).map: -> $chunk { my $n = [+] $chunk.map: { (%encodings{$_} || 0) +< ((state $m = 24) -= 6) } my $res = (16, 8, 0).map: { $n +> $_ +& 255 } slip( $res.head( 3 - ( 4 - $chunk.elems ) ) ); } ?$bin ?? Buf.new($ords || 0) !! $ords } my $str = decode-base64("dXNlcm5hbWU6dGhpc2lzbm90bXlwYXNzd29yZA==", :bin).decode; exit $str eq "username:thisisnotmypassword" ?? 0 !! 1;