- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert a stored MD5 string to a decimal value in MySQL?
You can use the conv() function along with the cast() to cast from hexadecimal to a decimal value.
Note − MD5 is in hexadecimal
Let us first create a table −
mysql> create table DemoTable ( Password text ); Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values("a5391e96f8d48a62e8c85381df108e98"); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values("ea7a32d2dc5bb793af262dcb6ea1a54d"); Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------------------------------+ | Password | +----------------------------------+ | a5391e96f8d48a62e8c85381df108e98 | | ea7a32d2dc5bb793af262dcb6ea1a54d | +----------------------------------+ 2 rows in set (0.00 sec)
Following is the query to convert a stored md5 string to a decimal value in MySQL −
mysql> select cast(conv(substr(Password, 1, 16), 16, 10) as decimal(65))*18446744073709551616 + cast(conv(substr(Password, 17, 16), 16, 10) as decimal(65)) AS DecimalValue from DemoTable;
This will produce the following output −
+-----------------------------------------+ | DecimalValue | +-----------------------------------------+ | 219619200658969319114298942978912194200 | | 311673842057003455136843080376797734221 | +-----------------------------------------+ 2 rows in set (0.00 sec)
- Related Articles
- Can we convert MD5 to SHA256 in a MySQL table with user password column?
- How to convert a decimal value or a vector of decimal values to fractional form in R?
- MySQL stored procedure to return a column value?
- C# Program to convert an Int32 value to a decimal
- Convert DateTime Value into String in MySQL?
- How to convert a boolean value to string value in JavaScript?
- How to convert a string to date in MySQL?
- How to convert a Date value to string in JDBC?
- How to convert a double value to String in Java?
- Python program to convert hex string to decimal
- Counting even decimal value substrings in a binary string in C++
- Convert Hexadecimal value String to ASCII value String in C++
- Java Program to convert a Primitive Type Value to a String
- Java program to convert decimal number to binary value
- Java program to convert decimal number to octal value

Advertisements