1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 08:08:02 +00:00

Add Compute The md5 Hash Of A String as a postgres til

This commit is contained in:
jbranchaud
2016-04-30 09:00:49 -05:00
parent 7c7e5f8120
commit cac58b4248
2 changed files with 24 additions and 1 deletions

View File

@@ -0,0 +1,22 @@
# Compute The md5 Hash Of A String
One of the functions provided by PostgreSQL for working with string data is
the `md5()` function. This function calculates the md5 hash of a given string.
It works like this:
```sql
> select md5('Hello, World!');
md5
----------------------------------
65a8e27d8879283831b664bd8b7f0ad4
> select md5('$3cr3tp4$$w0rd');
md5
----------------------------------
bbabecfd4031211077473734bae7249f
```
There are more hashing algorithms provided by the `pgcrypto` extension. See
[Compute Hashes With pgcrypto](postgres/compute-hashes-with-pgcrypto.md) for
more details on that.