A simple PHP library for hashing text, getting and verifying an user hash
Require this package, with Composer, in the root directory of your project.
composer require trihydera/hashutils
The HashID
class is designed to handle generating and verifying hashed user IDs based on the user's IP address.
- Instantiate the
HashID
class by providing an optional salt value. - Use the
gen()
method to generate a hashed ID based on the user's IP address. - Use the
verify($hash)
method to verify if a given hash matches the generated hash.
<?php
use Trihydera\Hashutils\HashID;
// Instantiate HashID class
$hashId = new HashID('mysalt');
// Generate a hashed ID
$generatedHash = $hashId->gen();
// Verify a hash
$isValid = $hashId->verify($generatedHash);
?>
The HashText
class is a PHP utility class that provides functionality to hash text content using different algorithms. It allows you to generate hashed strings for text content with added security through salting.
You can include the HashText
class in your project by requiring the relevant PHP file or using an autoloader.
- Instantiate the
HashText
class by providing an optional salt value. - Call the
gen($content)
method with the text content you want to hash. - The method will return a concatenated hash string generated using the specified algorithms.
<?php
use Trihydera\Hashutils\HashText;
// Instantiate HashText class with a custom salt
$hashText = new HashText('mysalt');
// Generate a hashed string for the text "Hello, World!"
$hashedContent = $hashText->gen('Hello, World!');
echo $hashedContent;
?>
- Supports hashing text content using the
md5
andsha256
algorithms. - Allows customization of the salt value for added security.
- Returns a concatenated hash string derived from multiple hashing algorithms.