public static function generate_secret(
		$data, $key=null, $length=64
	) {
		if (!$key)
			$key = uniqid() . (string)mt_rand();
		$bstr = $data . $key;
		$bstr = hash_hmac('sha256', $bstr, $key, true);
		$bstr = base64_encode($bstr);
		$bstr = str_replace(['/', '+', '='], '', $bstr);
		return substr($bstr, 0, $length);
	}