md5() - Message Digest Algorithm:
md5 -- Calculate the md5 hash of a string
Calculates the MD5 hash of str using the RSA Data Security, Inc. MD5 Message-Digest Algorithm, and returns that hash. The hash is a 32-character hexadecimal number.
$msg = "Evergreenphp123";
$encrypted_text = md5($msg);
echo "
Plain Text : ";
echo $msg;
echo "
Encrypted Text : ";
echo $encrypted_text;
?>
Note :
Once we encrypted the string using MD5() then we can't able to decrypt, we can again use the encrption of
the given string instead of decryption using below example.
Example :
$str = 'apple';
if (md5($str) === '1f3870be274f6c49b3e31a0c6728957f') {
echo "Valid string";
} else {
echo "Invalid string";
}
?>
Something about MD5:
- MD2 is a cryptographic hash function developed by Ronald Rivest in 1989.
- MD4 is a message digest algorithm (the fourth in a series) designed by Professor Ronald Rivest of MIT in 1990.
- MD4 is also used to compute NT-hash password digests on Microsoft Windows NT, XP and Vista.
- MD4 Weaknesses were demonstrated by Den Boer and Bosselaers in a paper published in 1991.
- MD5 was designed by Ron Rivest in 1991 to replace an earlier hash function, MD4.
Applications of MD5:
1. Encrypting the users password at Registration
2. Administrator itself not able to see the users password
3. Encrypting the users Activation code at the time of Registration
URL Encrypt and Decrypt
urlencode() -- URL-encodes string
urldecode() -- Decodes URL-encoded string
String Encrypt & Decrypt
Encryption
base64_encode -- Encodes data with MIME base64
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Example :
/* Encrypt */
$str = 'This is an encoded string';
echo base64_encode($str);
/*
Output :
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==
*/
?>
Decryption
base64_decode() -- Decodes data encoded with MIME base64
decodes encoded_data and returns the original data or FALSE on failure. The returned data may be binary.
Example :
/* Decrypt */
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);
/*
Output :
This is an encoded string
*/
?>
Subscribe to:
Post Comments (Atom)
Popular Posts
-
1. How old PHP language is? - PHP began in 1994, so 14 years old. 2. What are different names of PHP? - PHP originally stood for Persona...
-
HTML: a. HTML is a markup language that is used to build static (non interactive and nonanimated) webpages. b. HTML is Case-Insensitive. So...
-
A payment gateway is an e-commerce application service provider service that authorizes payments for e-businesses, online retailers, bricks...
-
Note : This is not a perfect sort order, we have just displaying the list of PHP companies. 1. Photon Infotech No. 2/102, Arvind IT Park (N...
-
- count() -- Count elements in a variable - syntax for count() [int count ( mixed var [, int mode])] - If the optional mode parameter is set...
-
Hai all, Simple show hide sample using Show/Hide? Simple Show/Hide code
-
Sharing PHP, MySQL, Javascript, CSS Knowledge, We can share our PHP knowledge on the basis of PHP versioning, Javascript, AJAX, Stylesheet, ...
-
Use the below code and you can get the exact value in php as us saw in browser. Code: $encode_data = iconv('UTF-8', 'windows-125...
-
Download and Enjoy!
-
A hyperlink is a text or a image that you can click on, and move from one page to another web page. Syntax: < a href= "web pag...
1 comment:
Good one.... keep ur work
Post a Comment