Tecknik.net: PHP SHA-1

What is PHP SHA-1?

PHP SHA-1 is a PHP implementation of the Secure Hash Algorithm, written as a collection of functions that can be included into any PHP script.

Hashing is something that is available to be built into PHP, but often is not. Most developers (including myself) do not have direct access to the PHP installation they use and, therefore, lack the ability to add the hashing libraries necessary. As PHP SHA-1 is simply the algorithm written in functions, there's no need to compile any libraries or recompile PHP.

Download PHP SHA-1

PHP SHA-1 was derived from a JavaScript implementation by Paul Johnston and, as such, is similarly available for use under the GNU Lesser General Public License:

PHP SHA-1 1.1

To use PHP SHA-1, you can either include the PHP file, or directly copy the functions, into your script. You can then call the sha1() function whenever you need to, with a string as its argument, which will return the hash as a 40-character hexadecimal number.

For example, sha1("Example string.") returns 6689a3c7c7305c432f2f78d07271dbab5baaff18.

Change Log

Fixed padding bug that could cause incorrect hashes. Thanks to Alberto Sáez for spotting this.

See Also

The PHP commonly stands for Hypertext Preprocessor. It's absolutely nothing but a server side scripting language that permits the world wide web developers to create dynamic content material to interrelate together with the database. PHP can be a scripting language much like the Active Server Pages. PHP is generally made use for producing internet centered software program application. PHP gives a healthy sturdy help to quite a large variety of databases like Oracle, Sybase, Solid,MySQL, Informix, and Generic Open DataBase Connectivity. PHP is really a no cost of charge to download and use. PHP may be created as scripts that exist around the server and it could create HTML output inorder to obtain the world wide web browser.

On the flip side PHP may be embedded and routed in HTML pages which are then saved having an extension of .php. Up coming the PHP sector of your pages are then parsed within the server with the PHP engine then the PHP code is removed out early prior to the pages are down load for the web browser. As PHP is embedded with tags the creator could transfer about concerning HTML and PHP inspite of making usage of a hefty number of codes. Because PHP is carried out and attained around the server, the codes are not visualized into the spectators. The very same job may be carried out and reached in PHP as a CGI method and it truly is well-matched with many different forms of databases.

When discussing with regards to the PHP file, the file has the opportunity to maintain text, scripts and HTML tags. Typically the PHP information possess a file extension of ".phtml", "/sha_1/.html" and ".php3". Ordinarily the PHP information are returned again on the browsers as a easy HTML code. Over all PHP functions like a filter. The PHP plan captures the input from your file or even a stream enclosing texts and also some individual facts directives and outputs one other stream of info for the look at. From PHP 4, the PHP parser compiles the input to crank out byte codes for dealing because of the Zend Engine for presenting a superior presentation in excess of its interpreter predecessor. The Zend Engine II is the central piece of PHP5. Scripting language is employed to develop interactivity of database and also to crank out dynamic subject material online that's usually employed with MySQL.

PHP is quite easy to know and understand. PHP has the ability to operate on quite a few platforms and in addition it runs much more effectively over the server facet. PHP is well-suited with all servers like IIS and Apache which are employed nowadays. PHP by no means expenses to obtain. It can be very easily downloaded from your official PHP resource. Scripting language and interpreter is acquired freely and it truly is mainly made use of on Linux World wide web servers. PHP is simply a substitution of ASP engineering. PHP is often a balanced in addition to a superior programming language which can be akin to ASP plus the only big difference is that it runs on UNIX servers in lieu of Windows centered servers. It is designed utilization of linking a database as well as to generate all kinds of internet programs like altering material, calendars, e-commerce and product catalogs.

Built with XHTML & CSS

Copyright 2003-2004 Marcus Campbell