...
32767POSThttps://api.dialogportal.com/v1/user20140408045941
The following C# method When encrypted using AppSecret RCL1EDAYOVHANLL3A51G, the encrypted token is:
S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ=
The complete signature will then look like this:
Code Block |
---|
Signature: {
"AppKey": 32767,
"IssuedAt": "20140408045941",
"Token": "S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ="
} |
Code Samples
The following code samples will return the encrypted token, using the AppSecret as the encryption key:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
public static string EncryptToken(string secret, string token) { byte[] bytesSecret = Encoding.UTF8.GetBytes(secret); using (var hmacsha256 = new HMACSHA256(bytesSecret)) { byte[] tokenBytes = Encoding.UTF8.GetBytes(token); return Convert.ToBase64String(hmacsha256.ComputeHash(tokenBytes)); } } |
When encrypted using AppSecret RCL1EDAYOVHANLL3A51G, the encrypted token is:
S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ=
The complete signature will then look like this:
Code Block |
---|
Signature: {
"AppKey": 32767,
"IssuedAt": "20140408045941",
"Token": "S/3bH3CD44NVM15UpuYds3iJEUp+xicCUZigXpghzaQ=" |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
public static function encryptToken($secret,$token)
{
$token_raw = hash_hmac("sha256", $token, $secret, true);
return base64_encode($token_raw);
} |