PHP Classes

File: src/helpers/misc.inc.php

Recommend this page to a friend!
  Classes of Pierre-Henry Soria   PHP RESTful API Example   src/helpers/misc.inc.php   Download  
File: src/helpers/misc.inc.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: PHP RESTful API Example
Example implementation of a REST API
Author: By
Last change:
Date: 7 months ago
Size: 402 bytes
 

Contents

Class file image Download
<?php
/**
 * Miscellaneous file (MISC)
 *
 * @author Pierre-Henry Soria <hi@ph7.me>
 * @license MIT License
 */

declare(strict_types=1);

const
PASSWORD_COST_FACTOR = 12;

function
response(mixed $data): void {
    echo
json_encode($data);
}

function
hashPassword(string $password): false|null|string {
   return
password_hash($password, PASSWORD_ARGON2I, ['cost' => PASSWORD_COST_FACTOR]);
}