$array = ['name' => 'John', 'age' => 30, 'city' => 'Los Angeles']; $hashed = password_hash('secretpassword', PASSWORD_DEFAULT); $array['password'] = $hashed; $password = hash_get('password', $array); echo $password; // output: hashed password
$post_data = json_decode(file_get_contents("php://input"), true); $token = hash_get('token', $post_data); if ($token != 'secrettoken') { http_response_code(401); exit(); } // continue with authorized actionIn this example, we retrieve a token value from the JSON post data using PHP Hash Get. We then use the token to determine if the request is authorized or not. The PHP Hash Get function is a built-in function in PHP and is part of the PHP core library. It is not dependent on any external package or library.