md5(), crc32() and sha1()

md5(), crc32() and sha1()

md5(), crc32() and sha1()

md5()

md5
- It 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. md5() returns a 160 bit value

Syntax:

string md5 ( string str)

crc32

crc32
- It Calculates the crc32 polynomial of a string.

Generates the cyclic redundancy checksum polynomial of 32-bit lengths of the

str. This is usually used to validate the integrity of data being transmitted.

Syntax:

int crc32 ( string str)

sha1

sha1()
Similarly, sha1 also generates a hash of a string in 128 bit value of

a string.

Syntax:

string sha1 ( string str)

Difference Between md5(), crc32() and sha1(),

The major difference is the length of the hash generated. CRC32

is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a

160 bit value. This is important when avoiding collisions.

Example:

echo md5(”test”);
It returns 098f6bcd4621d373cade4e832627b4f6

echo crc32(”test”);
It returns -662733300

echo sha1(”test”);
It returns a94a8fe5ccb19ba61c4c0873d391e987982fbbd3

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.