Sergio Tapia
Sergio Tapia

Reputation: 41158

Will a SHA256 hash always have 64 characters?

I'm setting up my database to receive hashed passwords and not accept plain text.

Would I go something like this?

create table User(
username varchar(20) not null,
password varchar(64) not null,
);

Upvotes: 54

Views: 66400

Answers (2)

OdinX
OdinX

Reputation: 4211

Yes, it will always have 64 characters.

Upvotes: 9

Julien Lebosquain
Julien Lebosquain

Reputation: 41243

Yes, a SHA256 is always 256 bits long, equivalent to 32 bytes, or 64 bytes in an hexadecimal string format. You can even use char(64) instead of varchar(64) since the size won't change.

Upvotes: 100

Related Questions