Skip to content

Instantly share code, notes, and snippets.

@acrosman acrosman/FA_Signing.php
Last active Apr 26, 2019

Embed
What would you like to do?
A PHP function to sign dynamic parameters for FormAssembly
<?php
function prepareFormAssemblyQueryString(array $parameters, $salt, $expire_timeout) {
$parts = [];
$signString = '';
foreach($parameters as $key => $value) {
$signString .= $key . $value;
$parts[] = rawurlencode($key) . '=' . rawurlencode($value);
}
$expireTime = time() + $expire_timeout;
$signString .= 'expire' . (string)$expireTime;
// hmach the signature string
$hash = hash_hmac('sha256', $signString, $salt, TRUE);
$sig = rawurlencode(base64_encode($hash));
$parts[] = 'signature=' . $sig;
$parts[] = 'expire=' . (string)$expireTime;
$queryString = implode('&', $parts);
return $queryString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.