Download the PHP package spoova/hasher without Composer
On this page you can find all versions of the php package spoova/hasher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spoova/hasher
More information about spoova/hasher
Files in spoova/hasher
Package hasher
Short Description Package for hashing data with multiple hashing algorithm
License MIT
Informations about the package hasher
Hasher
Hasher is a php package for generating dynamic or static hashes by combining varying hashing algorithms in a specific number of times.
Initializing Class
The hasher class can be instantiated as shown below
Definining Hash Data
The data to be hashed can be defined by using the method using the syntax below
- : data to be hashed
- : an optional secret key.
An example of data specified to be hashed is shown below
Defining Hashing Algorithm
The method is being used to define the hashing algorithm to be used for hashing a data. For example, after the method, we can supply a list of algorithms as below
In the code above, each function will be used for hashing the data specified in method
Processing and obtaining static hashed data
In order to execute the hashing and obtain the hash data the method is called. This method will execute and return the hashed data.
Process and return hashed data
The method also takes an integer parameter which makes it possible to execute the hashing in a number of specified times.
Processing and obtaining dynamic hashed data
While method returns a static hashed data by default, the returned data can be specified as dynamic through the method. This means that different hashed data will be generated when the method is called.
Generate a random hash from specified data
Generate a random hash by using dynamic functions
Behavioural Pattern of Hashify
The hashify function keeps track of its last state and generates a new hash once it is recalled. This means that every time method is called, a newly hashed data is generated from its last state. For example
In the code above, the hashify will continue to generate a new data until the hash node is restarted by supplying an argument of zero(0) to the hashify method. Once the hash node is restarted the data returned will be the first hash while the subsequent called will reflect its previous pattern. We may however try to be specific in the number of calls through the argument supplied. For example:
In the code above the data will be recorded as the same data with . This is because contains a data returned after three(3) successful calls of hashify. This data matches the exact number of times supplied as argument in the . This means that rather than running the without arguments for 4 consecutive times, we can easily supply the number of specific times of hash as arguments and the corresponding data will be returned. Also, in other to prevent
hashify()
from constantly changing, the first argument supplied must be false as shown below:The hashify function also assumes a list of hash function which overides any default declared if an array is supplied as first argument
In cases where two arguments are supplied, the first must be integer or boolean while the second array argument should contain the hashing algorithm. For example:
Generate an independent random hash
Other random hashes can be generated independently through the method. This method is a stand alone method that does not depend on any other method to perform its functions.
Generate random hash of specific length of characters
Generate random hash of specific length using specific range of characters
Generate random hash using specfied alogithms. Note that hash length can only be specified by the last algorithm used, hence the length is not applied.