Using MD5 Message Digest in PHP

This section provides a tutorial example on how to use MD5 message digest algorithm in PHP. The PHP engine has a built-in function md5().

If you are interested in using MD5 in PHP, you can use the built-in function md5(). Here is a sample program showing you how to use md5() function:

<?php 
# PhpMd5Test.php
# Copyright (c) HerongYang.com. All Rights Reserved.
# 
   $input = "";
   $output = md5($input);
   print("\n");
   print("MD5(\"".$input."\") =\n");
   print("   $output\n");

   $input = "abc";
   $output = md5($input);
   print("\n");
   print("MD5(\"".$input."\") =\n");
   print("   $output\n");

   $input = "abcdefghijklmnopqrstuvwxyz";
   $output = md5($input);
   print("\n");
   print("MD5(\"".$input."\") =\n");
   print("   $output\n");
?>

If you run this sample program with PHP 5, you should get:

MD5("") =
   d41d8cd98f00b204e9800998ecf8427e

MD5("abc") =
   900150983cd24fb0d6963f7d28e17f72
   
MD5("abcdefghijklmnopqrstuvwxyz") =
   c3fcd3d76192e4007dfb496cca67e13b

The output matches the testing result listed in RFC 1321.

Table of Contents

 About This Book

 Cryptography Terminology

 Cryptography Basic Concepts

 Introduction to AES (Advanced Encryption Standard)

 Introduction to DES Algorithm

 DES Algorithm - Illustrated with Java Programs

 DES Algorithm Java Implementation

 DES Algorithm - Java Implementation in JDK JCE

 DES Encryption Operation Modes

 DES in Stream Cipher Modes

 PHP Implementation of DES - mcrypt

 Blowfish - 8-Byte Block Cipher

 Secret Key Generation and Management

 Cipher - Secret Key Encryption and Decryption

 Introduction of RSA Algorithm

 RSA Implementation using java.math.BigInteger Class

 Introduction of DSA (Digital Signature Algorithm)

 Java Default Implementation of DSA

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Cipher - Public Key Encryption and Decryption

MD5 Mesasge Digest Algorithm

 What Is MD5 Message Digest Algorithm?

 MD5 Message Digest Algorithm Overview

 Using MD5 Message Digest in Java

Using MD5 Message Digest in PHP

 Using MD5 Message Digest in Perl

 SHA1 Mesasge Digest Algorithm

 OpenSSL Introduction and Installation

 OpenSSL Generating and Managing RSA Keys

 OpenSSL Managing Certificates

 OpenSSL Generating and Signing CSR

 OpenSSL Validating Certificate Path

 "keytool" and "keystore" from JDK

 "OpenSSL" Signing CSR Generated by "keytool"

 Migrating Keys from "keystore" to "OpenSSL" Key Files

 Certificate X.509 Standard and DER/PEM Formats

 Migrating Keys from "OpenSSL" Key Files to "keystore"

 Using Certificates in IE

 Using Certificates in Google Chrome

 Using Certificates in Firefox

 Archived Tutorials

 References

 Full Version in PDF/EPUB