PHP 8.3.31
Preview: Hmac.php Size: 1.08 KB
/home/getspomw/royalsquad.us/vendor/laravel/serializable-closure/src/Signers/Hmac.php

<?php

namespace Laravel\SerializableClosure\Signers;

use Laravel\SerializableClosure\Contracts\Signer;

class Hmac implements Signer
{
    /**
     * The secret key.
     *
     * @var string
     */
    protected $secret;

    /**
     * Creates a new signer instance.
     *
     * @param  string  $secret
     * @return void
     */
    public function __construct($secret)
    {
        $this->secret = $secret;
    }

    /**
     * Sign the given serializable.
     *
     * @param  string  $serialized
     * @return array
     */
    public function sign($serialized)
    {
        return [
            'serializable' => $serialized,
            'hash' => base64_encode(hash_hmac('sha256', $serialized, $this->secret, true)),
        ];
    }

    /**
     * Verify the given signature.
     *
     * @param  array{serializable: string, hash: string}  $signature
     * @return bool
     */
    public function verify($signature)
    {
        return hash_equals(base64_encode(
            hash_hmac('sha256', $signature['serializable'], $this->secret, true)
        ), $signature['hash']);
    }
}

Directory Contents

Dirs: 0 × Files: 2

Name Size Perms Modified Actions
1.37 KB lrw-r--r-- 2026-04-26 10:07:56
Edit Download
1.08 KB lrw-rw-rw- 2025-09-17 06:53:03
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).