Hasher - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of Hasher.php

  1. <?php
  2. $test = [
  3.         'articleId' => 'SW3456444',
  4.         'object' => [
  5.                         'prop1' => 1,
  6.                         'prop2' => '123Test'
  7.                 ]
  8.         ];
  9.        
  10. $test2 = [
  11.         'articleId' => 'SW3456444',
  12.         'object' => [
  13.                         'prop1' => 1,
  14.                         'prop2' => '124Test'
  15.                 ]
  16.         ];
  17.        
  18. $test3 = [
  19.         'articleId' => 'SW3456444',
  20.         'object' => [
  21.                         'prop1' => 1,
  22.                         'prop2' => '123Test'
  23.                 ]
  24.         ];
  25.        
  26. $testJson = json_encode($test);
  27. $checksum = md5($testJson);
  28. $hash = "{$checksum}_{$test['articleId']}";
  29.  
  30. $testJson2 = json_encode($test2);
  31. $checksum2 = md5($testJson2);
  32. $hash2 = "{$checksum2}_{$test2['articleId']}";
  33.  
  34. $testJson3 = json_encode($test3);
  35. $checksum3 = md5($testJson3);
  36. $hash3 = "{$checksum3}_{$test3['articleId']}";
  37.  
  38. echo "checksum: {$checksum}\n";
  39.  
  40. echo "article_id: {$test['articleId']} \n";
  41.  
  42. echo "hash: {$hash}\n\n";
  43.  
  44.  
  45.  
  46. echo "checksum2: {$checksum2}\n";
  47.  
  48. echo "article_id2: {$test2['articleId']} \n";
  49.  
  50. echo "hash2: {$hash2}\n\n";
  51.  
  52.  
  53.  
  54. echo "checksum3: {$checksum2}\n";
  55.  
  56. echo "article_id3: {$test2['articleId']} \n";
  57.  
  58. echo "hash3: {$hash2}\n\n";
  59.  
  60.  
  61. if($hash !== $hash2) {
  62.     echo "Object 1 and 2: \n";
  63.     echo "Object changed \n";
  64. } 
  65. if($hash === $hash3) {
  66.     echo "Object 1 and 3: \n";
  67.     echo "Object not changed \n";
  68. } 
File Description
  • Hasher
  • PHP Code
  • 11 Apr-2022
  • 1.13 Kb
You can Share it: