PHPackages                             hylianshield/validator-base-encoding - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. hylianshield/validator-base-encoding

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

hylianshield/validator-base-encoding
====================================

Base64, -32, -16 validation layer

2.0.3(9y ago)0551Apache-2.0PHPPHP ^7.0

Since Jan 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/HylianShield/validator-base-encoding)[ Packagist](https://packagist.org/packages/hylianshield/validator-base-encoding)[ RSS](/packages/hylianshield-validator-base-encoding/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (6)Used By (1)

Introduction
============

[](#introduction)

The base encoding validators allow the user to validate base64, -32 and -16 encoded messages. The validator will test if the string is encoded in the requested encoding.

Validators will validate against the specification of [RFC 4648](https://tools.ietf.org/html/rfc4648).

Additionally, the [Base32 Crockford](http://www.crockford.com/wrmg/base32.html)implementation is supported.

Installation
============

[](#installation)

```
composer require hylianshield/validator-base-encoding:^2.0
```

Usage
=====

[](#usage)

The encoding validators can be configured to require padding or make it optional. Additionally, some implementations require that partitioning will be supported.

[The RFC section on the interpretation of non-alphabet characters](https://tools.ietf.org/html/rfc4648#section-3.3)states:

> Implementations MUST reject the encoded data if it contains characters outside the base alphabet when interpreting base-encoded data, unless the specification referring to this document explicitly states otherwise. Such specifications may instead state, as MIME does, that characters outside the base encoding alphabet should simply be ignored when interpreting data ("be liberal in what you accept"). Note that this means that any adjacent carriage return/ line feed (CRLF) characters constitute "non-alphabet characters" and are ignored.

Therefore, the constructors of the validators have the following signature:

```
bool $requirePadding = true,
bool $allowPartitioning = false

```

With the exception of the `Base16Validator`, which does not use padding and therefore omits the first parameter, as well as the `Base32CrockfordValidator`, which requires padding and as such omits it as well.

Padding validation
==================

[](#padding-validation)

```
