承接 yohns/hash 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yohns/hash

最新稳定版本:0.5.0

Composer 安装命令:

composer require yohns/hash

包简介

A simple hashing technique for forms

README 文档

README

A secure and efficient PHP library for generating, validating, and managing tokens.

Installation

Install the package via Composer:

composer require yohns/hash

Usage

1. Generating a Token

Use the generateToken method to create a secure token.

use Yohns\Security\Finding\Hash;

$token = Hash::generateToken('form-id'); // This value will be used again to validate the token
// add token to form
echo '<input type="hidden" name="YohnsPatch" value="'.$token.'">';

2. Validating a Token

Verify the validity of a token with the validateToken method.

use Yohns\Security\Finding\Hash;

$isValid = Hash::validateToken('form-id', $_POST['YohnsPatch']);
if ($isValid) {
	echo 'Token is valid!';
} else {
	echo 'Token is invalid or expired.';
}

3. Garbage Collection

Remove expired tokens to maintain optimal performance.

use Yohns\Security\Finding\Hash;

Hash::garbageCollect();
echo 'Expired tokens removed.';

Running Tests

Ensure everything works as expected by running the test suite:

composer test

Requirements

License

This library is licensed under MIT License.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-22