kohana / ohanzee-helpers

Other
56 stars 10 forks source link

New properties, update Cookie::salt(), fix typo #2

Closed WinterSilence closed 10 years ago

WinterSilence commented 10 years ago
  1. Deleted text license, because it' s already defined tag @license
  2. Salt separator '~' moved into property Cookie::$separator, it will easily change the value if necessary
  3. Added Cookie::$hash_hmac and Cookie::$hash_hmac_algo properties, they used in Cookie::salt() for generate secure salt.

Why not alter the class in a singleton? Access to variables must be accessed through methods rather than directly, it would prevent their values. Example:

protected $hash_hmac_algo = 'sha512';

public function hashHmacAlgo($algo = null)
{
    if ($algo === null) {
        return $this->hash_hmac_algo;
    }

    if (! in_array($algo, hash_algos())) {
        // @todo create exceptions and replace it
        throw new InvalidArgumentException(
            sprintf('%s: unknown hashing algorithm `%s`.', __METHOD__, $algo),
        );
    }

    $this->hash_hmac_algo = $algo;

    return $this;
}
shadowhand commented 10 years ago

Too many things happening in this PR. Please separate the simple change of Cookie::$separator from the HMAC stuff and submit that as a second PR.

WinterSilence commented 10 years ago

how to share this PR? I've never done this

shadowhand commented 10 years ago

You will need to rebase and possibly use cherry-pick.