Generally, we use the MD5 and SHA password encryption algorithm in MySQL Application.
The MD5 and SHA password encryption algorithm is very famous for different application. The MySQL also provides a different function to use this method.
When we use the hashing algorithm, we should also create a fixed length data type to store encrypted string or password.
Whatever our input is, hashing algorithm always produces a result of the same length.
We can use CHAR or BINARY data type to store encrypted password.
We should choose hashing algorithm base on our requirements because there are different version available with the different bit size.
Generally, SHA-224 is recommended.
Below is a list of hashing algorithm along with its require bit size.
- MD5 = 128-bit hash value.
- SHA1 = 160-bit hash value.
- SHA224 = 224-bit hash value.
- SHA256 = 256-bit hash value.
- SHA384 = 384-bit hash value.
- SHA512 = 512-bit hash value.
Below is a small demonstration to create CHAR fixed length data type for different bit hash value.
First, create sample table and data with CHAR fixed length data type.
CREATE TABLE tbl_PasswordDataType
INSERT INTO tbl_PasswordDataType
Now check the size of this columns:
LENGTH(MD5_128_bit) AS Length_MD5128
,LENGTH(SHA_160_bit) AS Length_SHA160
,LENGTH(SHA_224_bit) AS Length_SHA224
,LENGTH(SHA_256_bit) AS Length_SHA256
,LENGTH(SHA_384_bit) AS Length_SHA384
,LENGTH(SHA_512_bit) AS Length_SHA512
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.