<?php

use App\Key;

if (!function_exists('gen_api_key')) {
    function gen_api_key()
    {
        $key = bin2hex(openssl_random_pseudo_bytes(10));
        while (Key::all()->where('api_key', '=', $key)->count() > 1) {
            $key = bin2hex(openssl_random_pseudo_bytes(10));
        }
        return $key;
    }
}
