for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PayumTW\Collect;
class Encrypter
{
/**
* $key.
*
* @var string
*/
public $key;
* setKey.
* @param string $key
public function setKey($key)
$this->key = $key;
return $this;
}
* encrypt.
* @param array $params
* @param array $filterKeys
* @return string
public function encrypt($params, $filterKeys = [])
if (empty($filterKeys) === false) {
$params = $this->filter($params, $filterKeys);
return isset($params['status']) === true
? $this->hash($params, ':')
: $this->hash(array_merge([$this->key], $params), '$');
* filter.
* @return array
protected function filter($params, $filterKeys)
$results = [];
foreach ($filterKeys as $key) {
if (isset($params[$key]) === true) {
$results[$key] = $params[$key];
return $results;
* hash.
* @param string $separate
protected function hash($params, $separate = '$')
return hash('md5', implode($separate, $params));