Category: php functions
How to Use md5_file()php function
md5 is a mathematical algorithm that is commonly called the md5 digest. The md5 procedure takes alphanumeric input and performs what is known as a hash returning a 128 bit unique sequence of 32 hexadecimal digits. This technique is used for security reasons. You will find cases of it used on the Internet when there is a file that is offered for download, included with the file will be a "hash" value. The idea is to download the file and then perform an md5 hash on it. If the number that is returned matches the hash value that was offered with the file -- the user can be reasonably sure that the file was not corrupted. The hash value becomes a type of fingerprint because the value of a file can only be produced by an identical copy the original.
This technique is also used for storing and retrieving passwords, especially on internet websites. The most common way to store a person's credentials in an online database is with the md5 hash. When the person submits their password it gets "hashed". The 32 character hash is what is stored in the database. This way if the database was compromised and the passwords retrieved, the attacker would have nothing more than a bunch of 32 character strings that are not to look at.
There was a time when the md5 was considered uncrackable. That has changed over the past decade. As computers grew more powerful and smaller, mathematicians were able to start working with larger sets of numbers and variables at faster speeds - in the end discovering that the md5 hash can be broken. It was discovered that with the rightnumber crunching hardware the algorithm will start returning duplicates. This fact officially makes the md5 unsuitable for serious security use.
Md5 is still popular and in widespread use for modern software, because it spent close to 2 two decades un-cracked. Until recently, within a few short years, software vendors felt sure that md5 was a one way encryption that they could rely on, so they integrated into many of the password routines found in popular software such as Wordpress and OsDate.
Thus far we have discussed the md5 algorithm. Now let us take a look at how to use it in our php scripts.
- Create a folder called md5.
- Create a file called test_file.txt and save it in the md5 folder.
- Create another file called md5_file.php and save it in the md5 folder.
- Write the word "Testing" into the test_file.txt
- Copy and paste the script below into the md5_file.php file and save it
$testfile = 'test_file.txt';
$hash = md5_file($testfile);
rtrim See Also:
chop chop() PHP Function
chop() is identical to the rtrim function —
string rtrim(string $str[, string $charlist ])
Strips characters including he
strip tags StripTags() php function
Striptags() is a php function that literally strips HTML tags out of files that are streamed in to php with a function like
parse str How to use parse_str()
parse_str(string $str [,array &$arr ])
$string = 'firstVar=first&
echo Echo is used in php scripts to output html characters to the screen. echo is one of the most used functions in the php language.