Syntax error How long is the SHA256 hash in MySQL?

How long is the SHA256 hash in MySQL?



As the name "SHA256" suggest, it is 256 bits long. If we are using hexadecimal notation then digit codes represent 4 bits. In order to represent 256, we need 256/4 = 64 bits. We need a data type varchar(64) or char(64).

Creating a table for our example.

mysql> create table SHA256Demo
   -> (
   -> Password varchar(64)
   -> );
Query OK, 0 rows affected (0.54 sec)

Inserting records into table.

mysql> insert into SHA256Demo values(' 4e2e1a39dba84a0b5a91043bb0e4dbef23970837');
Query OK, 1 row affected (0.18 sec)

Displaying all records.

mysql> select *From SHA256Demo;

The following is the output.

+-------------------------------------------+
| Password                                  |
+-------------------------------------------+
|  4e2e1a39dba84a0b5a91043bb0e4dbef23970837 |
+-------------------------------------------+
1 row in set (0.00 sec)
Updated on: 2019-07-30T22:30:23+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements