User Tools

Site Tools


uphp:functions:sha1

Differences

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

Link to this comparison view

Next revision
Previous revision
uphp:functions:sha1 [2017/05/16 06:14]
admin created
uphp:functions:sha1 [2019/08/16 09:42]
admin [See Also]
Line 1: Line 1:
-====== sha1($str) ====== +======sha1======
-Calculate the sha1 hash of a string.  This can be used for cryptography or just for checksum calculations.+
  
-For more information on SHA1see the [[https://en.wikipedia.org/wiki/SHA-1|Wikipedia link]].+<badge>WMPROWMMINI FW >= 1.1015</badge> <badge>WMMEGA FW >= 2.0</badge>
  
-Example:+Calculate the SHA1 hash of a <html><b><span style="color:green">string</b></html>
  
-<code php> +====Description====
-<pre> +
-<?  +
-// call the function with this: sha1.cgi?key=secretkey+
  
-// sha1 hash value for secretykey +<well size="sm"><html> 
-$hash = "9885F8AF04289135DF259E34BD22D17FE45EA81E";+<span style="font-size:125%;color:green">string 
 +<span style="color:black">sha1 ( 
 +<span style="color:green">string 
 +<span style="color:blue">$input 
 +<span style="color:black">) 
 +</html></well>
  
-if (sha1($_GET['key']) == $hash) { +This can be used for cryptography or just for checksum calculations.
-        print("hashes match!"); +
-}+
  
-?> +For more information on SHA1, see this [[https://en.wikipedia.org/wiki/SHA-1|Wikipedia link]].
-</pre>+
  
 +====Parameter====
 +
 +<html><b><span style="color:blue">$input<span style="color:black"></b>:  A <b><span style="color:green">string<span style="color:black"></b></html>
 +
 +====Return Values====
 +
 +<html><b><span style="color:green">String<span style="color:black"></b>:  SHA1 hash (40 character hexadecimal number) of <b><span style="color:blue">input</b></html>
 +
 +====Example====
 +
 +<code php>
 +<?
 +  // Name this example and call it with this: sha1.cgi?key=secretkey
 +
 +  // SHA1 hash value for "secretkey":
 +  $hash="9885F8AF04289135DF259E34BD22D17FE45EA81E";
 +
 +  if (sha1($_GET['key']) == $hash) {
 +    print("hashes match!");
 +  }
 +?>
 </code> </code>
 +
 +====See Also====
 +
 +[[md5()]] - Calculate the MD5 hash of a <html><b><span style="color:green">string</b></html>
 +
 +[[md5_file()]] - Calculate the MD5 hash of a file
 +
 +[[hash_hmac()]] - Calculate the hash of a string
 +
 +[[aes_decrypt()]] - Decrypt a string using the AES algorithm
 +
 +[[aes_encrypt()]] - Encrypt a string using the AES algorithm
uphp/functions/sha1.txt · Last modified: 2021/09/13 05:57 (external edit)