PHP Helper类,用于从要传递给url的数组生成散列键

Helper Class to generate a unique key from the values of an array. I have a home page search form where user selects different option to go next page. If I save the search in session User cannot make multiple orders be opening in a new tab.The only solution is to pass the search fields in the url. Since there is a limitation of the url length . I want to generate a hash value of the search data and pass it on to the url. Is there a better way to generate the hash value.

Only simple solution I have found is woocommerce cart key generation which uses md5 to generate the key.

class HashKey extends Object
{

    public $model;
    public $hashkey;

    public function __construct($model)
    {
            $attributes = $model->getAttributes();
            if ( is_array( $attributes ) && ! empty( $attributes ) ) {
                $hashkey = '';
                foreach ( $attributes as $key => $value ) {
                    if ( is_array( $value ) ) $value = http_build_query( $value );
                    $hashkey .= trim($key) . trim($value);
                }
                $id_parts[] = $hashkey;
            }


        $this->hashkey = md5( implode( '_', $id_parts ) );

    }

    /**
     * String magic method
     * @return string the DB expression
     */
    public function __toString()
    {
        return $this->hashkey;
    }
}