Home >Backend Development >PHP Tutorial >Implementation skills of php custom hash function
This article mainly introduces the PHP custom hash function, and analyzes the implementation skills of the hash function with examples. It can realize simple encryption functions and has certain reference value. Friends in need can refer to this article
The example describes the implementation method of PHP custom hash function. The specific analysis is as follows:
Here demonstrates a simple hash algorithm implemented in PHP, which can be used for encryption, but this function is too simple and cannot be used for decryption
function SimpleHash($str){ $n = 0; // The magic happens here: // I just loop trough all letters and add the // ASCII value to a integer variable. for ($c=0; $c < strlen($str); $c++) $n += ord($str[$c]); // After we went trough all letters // we have a number that represents the // content of the string return $n; }
Calling method:
$TestString = 'www.jb51.net'; print SimpleHash($TestString); // returns: 1082
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
How to automatically generate forms in PHP
php predefined variables on the server side$ _SERVER method
php method of operating MySQL database
The above is the detailed content of Implementation skills of php custom hash function. For more information, please follow other related articles on the PHP Chinese website!