tankfairies/guid
最新稳定版本:2.0.3
Composer 安装命令:
composer require tankfairies/guid
包简介
GUID Generator
关键字:
README 文档
README
GUID
It's PHP 7.1+ (master) and PHP 8.2 (2.0) library for generating and working with [RFC 4122][rfc4122] version 1, 3, 4, and 5 universally unique identifiers (UUID) / globally unique identifiers (GUID).
Derived from code by Fredrik Lindberg.
Installation
Install with Composer:
composer require tankfairies/guid
API documentation
The [latest class API documentation][apidocs] is available online.
Usage
There are four GUID types available. GUID Version: -
GuidInterface::UUID_TIME -> Time based UUID (version 1)
GuidInterface::UUID_NAME_MD5 -> Name based (MD5) UUID (version 3)
GuidInterface::UUID_RANDOM -> Random UUID (version 4)
GuidInterface::UUID_NAME_SHA1 -> Name based (SHA1) UUID (version 5)
All the GUIDs can be generated in one of three formats String, binary and byte. GUID format: -
GuidInterface::FMT_STRING
GuidInterface::FMT_BINARY
GuidInterface::FMT_BYTE
The guid generate function has four parameters: -
$guid->generate(
version,
format,
salt,
namespace
)
The salt needs to be at least 6 characters long.
A salt is required for versions 1 but optional for versions 3 and 5.
Generate a Version one GUID. (The third parameter is a salt and is required).
use Tankfairies\Guid\Guid; $guid = new Guid(); $guidToken = $guid->generate( GuidInterface::UUID_TIME, GuidInterface::FMT_STRING, 'thesalt' );
Generate a Version three GUID.
use Tankfairies\Guid\Guid; $guid = new Guid(); $guidToken = $guid->generate( GuidInterface::UUID_NAME_MD5, GuidInterface::FMT_STRING, 'thesalt', 'thenamespace' );
Generate a Version four GUID.
use Tankfairies\Guid\Guid; $guid = new Guid(); $guidToken = $guid->generate( GuidInterface::UUID_RANDOM, GuidInterface::FMT_STRING );
Generate a Version five GUID.
use Tankfairies\Guid\Guid; $guid = new Guid(); $guidToken = $guid->generate( GuidInterface::UUID_NAME_SHA1, GuidInterface::FMT_STRING );
Copyright and license
The tankfairies/guid library is Copyright (c) 2019 Tankfairies (https://tankfairies.com) and licensed for use under the MIT License (MIT).
统计信息
- 总下载量: 1.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-15