Skip to content

Instantly share code, notes, and snippets.

@blessdyb
Created July 7, 2014 08:05
Show Gist options
  • Save blessdyb/8848f1a7799ff4559e5c to your computer and use it in GitHub Desktop.
Save blessdyb/8848f1a7799ff4559e5c to your computer and use it in GitHub Desktop.
Several php authentication security method
function md5_auth() {
$current_time = time();
$hash_str = join("", array(MD5_SALT_KEY, $current_time));
return array(
'current_time' => $current_time,
'token' => base64_encode(md5($hash_str)),
);
}
function swt_auth($parameters) {
// Build an HMAC-SHA1 signature using the multipass string and your API key
$signature = hash_hmac("sha1", $parameters, HAMC_KEY, true);
// Base64 encode the signature
$signature = base64_encode($signature);
return $signature;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment