am_dot_com

ACA 20201117

Nov 17th, 2020 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.32 KB | None | 0 0
  1. <?php
  2. /*
  3.  * message digesting examples
  4.  * Message digesting algorithms are "injective" mathematical
  5.  * functions that will necessarily produce a different
  6.  * output per each different input
  7.  */
  8. $source = $argv[1];
  9. $md5 = md5($source);
  10. $iSizeMd5 = strlen($md5);
  11.  
  12. $strMsgMd5 =
  13.     sprintf(
  14.         "algo: %s\ninput: %s\nouput: %s (%d symbols)\n",
  15.         "MD5",
  16.         $source,
  17.         $md5,
  18.         $iSizeMd5
  19.     );
  20.  
  21. echo $strMsgMd5;
  22.  
  23. //*****************
  24.  
  25. echo PHP_EOL;
  26.  
  27. $sha1 = hash("sha1", $source);
  28. $iSizeSha1 = strlen($sha1);
  29.  
  30. $strMsgSha1 =
  31.     sprintf(
  32.         "algo: %s\ninput: %s\nouput: %s (%d symbols)\n",
  33.         "sha1",
  34.         $source,
  35.         $sha1,
  36.         $iSizeSha1
  37.     );
  38.  
  39. echo $strMsgSha1;
  40.  
  41. //*****************
  42.  
  43. echo PHP_EOL;
  44.  
  45. $sha256 = hash("sha256", $source);
  46. $iSizeSha256 = strlen($sha256);
  47.  
  48. $strMsgSha256 =
  49.     sprintf(
  50.         "algo: %s\ninput: %s\nouput: %s (%d symbols)\n",
  51.         "sha256",
  52.         $source,
  53.         $sha256,
  54.         $iSizeSha256
  55.     );
  56.  
  57. echo $strMsgSha256;
  58.  
  59. //**
  60.  
  61. echo PHP_EOL;
  62.  
  63. $sha512 = hash("sha512", $source);
  64. $iSizeSha512 = strlen($sha512);
  65.  
  66. $strMsgSha512 =
  67.     sprintf(
  68.         "algo: %s\ninput: %s\nouput: %s (%d symbols)\n",
  69.         "sha512",
  70.         $source,
  71.         $sha512,
  72.         $iSizeSha512
  73.     );
  74.  
  75. echo $strMsgSha512;
Advertisement
Add Comment
Please, Sign In to add comment