* Signs the given value with the signature secret.
*
* @param string $value
- * @return string
* @throws CryptoException
*/
- public static function getSignature($value) {
+ public static function getSignature($value): string {
if (mb_strlen(SIGNATURE_SECRET, '8bit') < 15) throw new CryptoException('SIGNATURE_SECRET is too short, aborting.');
return hash_hmac('sha256', $value, SIGNATURE_SECRET);
* Creates a signed (signature + encoded value) string.
*
* @param string $value
- * @return string
*/
- public static function createSignedString($value) {
+ public static function createSignedString($value): string {
return self::getSignature($value).'-'.Base64::encode($value);
}
* (i.e. consists of a valid signature + encoded value)
*
* @param string $string
- * @return boolean
*/
- public static function validateSignedString($string) {
+ public static function validateSignedString($string): bool {
$parts = explode('-', $string, 2);
if (count($parts) !== 2) return false;
list($signature, $value) = $parts;
* - Returns null if the string is not properly signed.
*
* @param string $string
- * @return null|string
* @see \wcf\util\CryptoUtil::validateSignedString()
*/
- public static function getValueFromSignedString($string) {
+ public static function getValueFromSignedString($string): ?string {
if (!self::validateSignedString($string)) return null;
$parts = explode('-', $string, 2);