-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mnavarrocarter/2.x
Version 2.0.0 implemented.
- Loading branch information
Showing
19 changed files
with
425 additions
and
454 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: "Review PR" | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
|
||
# This job ensures the coding standard is followed | ||
coding-standards: | ||
name: "Coding Standards" | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
php-version: | ||
- "7.2" | ||
operating-system: | ||
- "ubuntu-latest" | ||
steps: | ||
- name: "Checkout Code" | ||
uses: "actions/checkout@v2" | ||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: "pcov" | ||
php-version: "${{ matrix.php-version }}" | ||
ini-values: memory_limit=-1 | ||
- name: "Use Cache" | ||
uses: "actions/cache@v2" | ||
with: | ||
path: | | ||
~/.composer/cache | ||
vendor | ||
key: "php-${{ matrix.php-version }}-locked" | ||
restore-keys: "php-${{ matrix.php-version }}-locked" | ||
- name: "Install locked dependencies" | ||
run: "composer install --no-interaction --no-progress --no-suggest" | ||
- name: "Coding Standard" | ||
run: "vendor/bin/php-cs-fixer fix --dry-run -vvv" | ||
|
||
type-analysis: | ||
name: "Type Coverage" | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
php-version: | ||
- "7.2" | ||
operating-system: | ||
- "ubuntu-latest" | ||
steps: | ||
- name: "Checkout Code" | ||
uses: "actions/checkout@v2" | ||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: "pcov" | ||
php-version: "${{ matrix.php-version }}" | ||
ini-values: memory_limit=-1 | ||
- name: "Use Cache" | ||
uses: "actions/cache@v2" | ||
with: | ||
path: | | ||
~/.composer/cache | ||
vendor | ||
key: "php-${{ matrix.php-version }}-locked" | ||
restore-keys: "php-${{ matrix.php-version }}-locked" | ||
- name: "Install locked dependencies" | ||
run: "composer install --no-interaction --no-progress --no-suggest" | ||
- name: "Run Psalm" | ||
run: "vendor/bin/psalm --output-format=github --shepherd --stats" | ||
|
||
unit-test: | ||
name: "Unit Testing" | ||
runs-on: ${{ matrix.operating-system }} | ||
strategy: | ||
matrix: | ||
dependencies: | ||
- "locked" | ||
- "highest" | ||
php-version: | ||
- "7.2" | ||
- "7.3" | ||
- "7.4" | ||
operating-system: | ||
- "ubuntu-latest" | ||
steps: | ||
- name: "Checkout Code" | ||
uses: "actions/checkout@v2" | ||
- name: "Install PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
coverage: "pcov" | ||
php-version: "${{ matrix.php-version }}" | ||
ini-values: memory_limit=-1 | ||
- name: "Use Cache" | ||
uses: "actions/cache@v2" | ||
with: | ||
path: | | ||
~/.composer/cache | ||
vendor | ||
key: "php-${{ matrix.php-version }}-locked" | ||
restore-keys: "php-${{ matrix.php-version }}-${{ matrix.dependencies }}" | ||
- name: "Install lowest dependencies" | ||
if: ${{ matrix.dependencies == 'lowest' }} | ||
run: "composer update --prefer-lowest --no-interaction --no-progress --no-suggest" | ||
- name: "Install highest dependencies" | ||
if: ${{ matrix.dependencies == 'highest' }} | ||
run: "composer update --no-interaction --no-progress --no-suggest" | ||
- name: "Install locked dependencies" | ||
if: ${{ matrix.dependencies == 'locked' }} | ||
run: "composer install --no-interaction --no-progress --no-suggest" | ||
- name: "Run PHPUnit" | ||
run: "vendor/bin/phpunit --testdox --coverage-text" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace MNC\Fernet\UrlBase64; | ||
|
||
use InvalidArgumentException; | ||
|
||
/** | ||
* @param string $data | ||
* @return string | ||
*/ | ||
function encode(string $data): string | ||
{ | ||
return str_replace(['+', '/'], ['-', '_'], base64_encode($data)); | ||
} | ||
|
||
/** | ||
* @param string $base64 | ||
* @return string | ||
* @throws InvalidArgumentException on decoding error | ||
*/ | ||
function decode(string $base64): string | ||
{ | ||
$result = base64_decode(str_replace(['-', '_'], ['+', '/'], $base64), true); | ||
if (!is_string($result)) { | ||
throw new \InvalidArgumentException('Invalid url encoded base64 string provided'); | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
|
||
namespace MNC\Fernet\Str; | ||
|
||
use Exception; | ||
use InvalidArgumentException; | ||
|
||
/** | ||
* Pads a message to a multiple of 16 bytes. | ||
* | ||
* @param string $message | ||
* | ||
* @return string | ||
*/ | ||
function pad(string $message): string | ||
{ | ||
$pad = 16 - (strlen($message) % 16); | ||
$message .= str_repeat(chr($pad), $pad); | ||
return $message; | ||
} | ||
|
||
/** | ||
* Removed the padding of a message. | ||
* | ||
* @param string $paddedMessage | ||
* | ||
* @return string | ||
* @throws InvalidArgumentException on padding error | ||
*/ | ||
function unpad(string $paddedMessage): string | ||
{ | ||
$pad = ord($paddedMessage[strlen($paddedMessage) - 1]); | ||
if ($pad !== substr_count(substr($paddedMessage, -$pad), chr($pad))) { | ||
throw new InvalidArgumentException('Padding error'); | ||
} | ||
|
||
return substr($paddedMessage, 0, -$pad); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.