rikby / crypter
Simple tool for encrypting/decrypting a string. It based upon system ID.
1.0.0
2016-08-22 21:14 UTC
Requires
- php: >=5.4
This package is not auto-updated.
Last update: 2024-12-25 20:18:48 UTC
README
Simple tool for encrypting/decrypting a string. It based upon system ID.
$ composer require rikby/crypter
Using example:
/** * Class Password */ class Password extends Crypter implements CrypterInterface { /** * Get password * * @param string $trackerType * @return null|string * @throws \Exception */ public function getPassword($trackerType) { try { //get saved encrypted password $password = SomeClass::getPostPassword(); if (!$password) { return null; } return $this->decrypt($password) ?: null; } catch (\Exception $e) { throw new UserException('Cannot get password of tracker.', 0, $e); } } /** * Replace strange \000 character * * {@inheritdoc} */ public function decrypt($string, $key = null) { $password = parent::decrypt($string, $key); /** * Unknown bug in PhpStorm * Only PHPStorm adds \0 to the tail of password * Perhaps PHP versions conflict */ return rtrim($password, "\000"); } }