\Gishiki\AlgorithmsBase64

An helper class for base64 algorithm.

Summary

Methods
Properties
Constants
encode()
decode()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

encode()

encode(string  $message) : string

Create the Base64 binary-safe representation of the given message.

The generated base64 is different from the stock PHP implementation as the generated string can be used on URLs.

The given message can be a binary unsafe string.

Example of usage: //this is the binary unsafe message $message = " ... ";

//print the result var_dump(Base64::encode($message));

Parameters

string $message

the binary-unsafe message

Throws

\InvalidArgumentException

the given message is not represented as a string or the URL safety is not boolean

Returns

string —

the binary-safe representation of the given message

decode()

decode(string  $message) : string

Get the binary-unsafe representation of the given base64-encoded message.

This function is compatible with the php standard base64_encode and the framework Base64::encode( ... ).

Example of usage: //this is the binary unsafe message $message = " ... ";

//print the input string (binary unsafe) var_dump(Base64::decode(Base64::encode($message)));

Parameters

string $message

a message base64 encoded

Throws

\InvalidArgumentException

the given message is not represented as a string

Returns

string —

the message in a binary-unsafe format