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.
Result of php executing
Full code of Hasher.php
- <?php
- $test = [
- 'articleId' => 'SW3456444',
- 'object' => [
- 'prop1' => 1,
- 'prop2' => '123Test'
- ]
- ];
- $test2 = [
- 'articleId' => 'SW3456444',
- 'object' => [
- 'prop1' => 1,
- 'prop2' => '124Test'
- ]
- ];
- $test3 = [
- 'articleId' => 'SW3456444',
- 'object' => [
- 'prop1' => 1,
- 'prop3' => '123Test'
- ]
- ];
- $testJson = json_encode($test);
- $checksum = password_hash($testJson, PASSWORD_BCRYPT);
- $hash = "{$checksum}_{$test['articleId']}";
- $testJson2 = json_encode($test2);
- $checksum2 = password_hash($testJson2, PASSWORD_BCRYPT);
- $hash2 = "{$checksum2}_{$test2['articleId']}";
- $testJson3 = json_encode($test3);
- $checksum3 = password_hash($testJson3, PASSWORD_BCRYPT);
- $hash3 = "{$checksum3}_{$test3['articleId']}";
- echo "checksum: {$checksum}\n";
- echo "article_id: {$test['articleId']} \n";
- echo "hash: {$hash}\n\n";
- echo "checksum2: {$checksum2}\n";
- echo "article_id2: {$test2['articleId']} \n";
- echo "hash2: {$hash2}\n\n";
- echo "checksum3: {$checksum3}\n";
- echo "article_id3: {$test3['articleId']} \n";
- echo "hash3: {$hash3}\n\n";
- if($hash !== $hash2) {
- echo "Object 1 and 2: \n";
- echo "Object changed \n";
- }
- if($hash === $hash3) {
- echo "Object 1 and 3: \n";
- echo "Object not changed \n";
- }