furbyus/hashing 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

furbyus/hashing

Composer 安装命令:

composer require furbyus/hashing

包简介

Hashing library to wrap and extend hash() hash_hmac() crc() md5() functions

README 文档

README

Furbyus\Hashing

This library is intended to wrap and extend the hash(), hash_hmac() and other PHP functions like crc() or md5() in an OOP paradigm, including contructor or static method makers way.

Example:

<?php

use Furbyus\Hashing\Hash;
use Furbyus\Hashing\Enum\HashAlgo;

/**
* Generation of non-cryptographic Hash
* See Furbyus\Hashing\Enum\HashAlgo for the entire list of available Algorithms
* there will be minimum all the algos returned by hash_algos() PHP function, plus some more (Ex. CRC32TS)
*/
$hashValue = Hash::make("My data", HashAlgo::MURMUR3A);
// OR
$hashValue = Hash::make("My data", HashAlgo::CRC32);

/**
* Generation of cryptographic Hash
*/
$secretKey = "someSecret";

$hashValue = Hash::make("My data", HashAlgo::SHA512, $secretKey);
// OR
$hashValue = Hash::make("My data", HashAlgo::RIPEMD256, $secretKey);

/**
* Comparing cryptographic Hash (Validating a known Hash vs the user inputs)
*/

$result = Hash::compare($knownHash, $data, $algorithm, $key); // returns True only if the $knownHash have been generated with the same $data, $algorithm and $key provided. False otherwise
// Real world usage example | Values faked ;) 
$savedHashedPassword = "dkljnscfdajklnsacdljnvscdjln"; 
$data = "user=userName";
$secret = "userPassword";

if(!Hash::compare($savedHashedPassword, $data, HashAlgo::SHA512, $secret)){
    throw new \Exception("User & Password combination invalid!");
}else{
    // User authenticated by username & password!
}

统计信息

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

GitHub 信息

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

其他信息

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