[solved] SecureToken calculated hash does not match

Issue resolved, just wanted to post this for anyone else.

The SHA must be in BINARY before getting converted to base64. It does not say this in the documentation. I was encoding the SHA string. Im not sure why this has to be in binary and then converted to base64, SHA is already a string…

In PHP you must set the RAW parameter to true.

$hash = hash('sha256', $input, true);

I’ve been setting up SecureToken and cannot get the hashes to match.

Here are the results I get from the log:

2017-03-07	23:04:19	UTC	comment	server	INFO	200	-	[vod/_definst_]ModuleCoreSecurity:hashCalculated: jbGXphGTxO570_89Y_dpBTA1KUCtTGdVCKXXHjTkhDU=	-	-	-	0.029	-	-	-	-	--	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-	-
2017-03-07	23:04:19	UTC	comment	server	INFO	200	-	[vod/_definst_]ModuleCoreSecurity:string hashed: vod/sample.mp4?mySharedSecret&myTokenPrefixCustomParameter=abcdef&myTokenPrefixendtime=1500000000&myTokenPrefixstarttime=1395230400	-	-	-	0.029	-	-	-	-	-	-	-	-	-	-	-	-

If I were to calculate this hash myself:

$input = 'vod/sample.mp4?mySharedSecret&myTokenPrefixCustomParameter=abcdef&myTokenPrefixendtime=1500000000&myTokenPrefixstarttime=1395230400';
$hash = base64_encode(hash('sha256', $input));

The hash result I get is:

OGRiMTk3YTYxMTkzYzRlZTdiZDNmZjNkNjNmNzY5MDUzMDM1Mjk0MGFkNGM2NzU1MDhhNWQ3MWUzNGU0ODQzNQ==

This is not even close to what wowza is calculating for the hash, and this is set as SHA-256 in wowza