User Tools

Site Tools


uphp:functions:hash_hmac

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

uphp:functions:hash_hmac [2019/08/16 09:43]
admin [See Also]
uphp:functions:hash_hmac [2021/09/13 05:57]
Line 1: Line 1:
-======hash_hmac====== 
  
-<badge>WMMEGA FW >= 2.1030</badge> <badge>WM2 FW >= 3.1130</badge> 
- 
-Generate a keyed hash value using the HMAC method 
- 
-====Description==== 
- 
-<well size="sm"><html> 
-<span style="font-size:125%;color:green">string 
-<span style="color:black">hash_hmac ( 
-<span style="color:green">string 
-<span style="color:blue">$algorithm 
-<span style="color:black">,  
-<span style="color:green">string 
-<span style="color:blue">$data 
-<span style="color:black">, 
-<span style="color:green">string 
-<span style="color:blue">$key 
-<span style="color:black">) 
-</html></well> 
- 
-This can be used for cryptography or just for checksum calculations. 
- 
- 
-====Parameter==== 
- 
-<html><b><span style="color:blue">$algorithm<span style="color:black"></b>:  Name of selected hashing algorithm. Current algorithms supported are: </html> 
-^ Parameter  ^ Algorithm  ^ Return Size (characters)  | 
-| md5        | MD5        | 32                   | 
-| sha1       | SHA-1      | 40                   | 
-| sha224     | SHA-224    | 56                   | 
-| sha256     | SHA-256    | 64                   | 
-| sha384     | SHA-384    | 96                   | 
-| sha512     | SHA-512    | 128                  | 
- 
-<html><b><span style="color:blue">$data<span style="color:black"></b>:  String of characters to calculate hash for</html> 
- 
-<html><b><span style="color:blue">$key<span style="color:black"></b>:  String of characters of key to be used in hash calculation </html> 
-====Return Values==== 
- 
-<html><b><span style="color:green">String<span style="color:black"></b>:  Hash result (as hexadecimal number) of <b><span style="color:blue">data</b></span> See above for expected length</html> 
- 
-====Example==== 
- 
-<code php> 
-<? 
- 
-// Get the parameters from the URL 
- 
-$algo=$_GET['algorithm']; 
-$key=$_GET['key'];; 
-$data=$_GET['data']; 
- 
- 
-// make sure parameters are passed properly 
-if (!$algo) { 
-    print("You need to specify an algorithm"); 
-    die(); 
-} 
-if (!$key) { 
-    print("You need to specify a key"); 
-    die(); 
-} 
-if (!$data) { 
-    print("You need to specify a data parameter"); 
-    die(); 
-} 
- 
-// calculate the hash 
-$res = hash_hmac($algo,$data,$key); 
- 
-// output the rsults 
-print($algo." hash for key ".$key." and data ".$data." = ".$res); 
- 
-?> 
- 
-</code> 
- 
-====See Also==== 
- 
-[[md5()]] - Calculate the MD5 hash of a <html><b><span style="color:green">string</b></html> 
- 
-[[sha1()]] - Calculate the SHA-1 hash of a <html><b><span style="color:green">string</b></html> 
- 
-[[md5_file()]] - Calculate the MD5 hash of a file 
- 
-[[aes_decrypt()]] - Decrypt a string using the AES algorithm 
- 
-[[aes_encrypt()]] - Encrypt a string using the AES algorithm 
uphp/functions/hash_hmac.txt · Last modified: 2021/09/13 05:57 (external edit)