# SHA1()/SHA()

## Function description

The `SHA1()/SHA()` function is a cryptographic hash function that calculates and returns the SHA-1 hash value of a given string, which converts an input message of any length into a fixed length (160 bits, i.e. 20 bytes) hash value, usually expressed as 40 hexadecimal characters. If the parameter is NULL, NULL is returned.

## Function Syntax

```text
> SHA1/SHA(str)
```

## Parameter definition

| Parameters | Description |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| str | Required parameters. String to encrypt |

## Example

```text
mysql> select sha1("hello world");
+-----------------------------------------------------+
| sha1(hello world) |
+-----------------------------------------------------+
| 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed |
+-----------------------------------------------------+
1 row in set (0.00 sec)

mysql> select sha("hello world");
+-----------------------------------------------------+
| sha(hello world) |
+-----------------------------------------------------+
| 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed |
+-----------------------------------------------------+
1 row in set (0.00 sec)

mysql> select sha1(null);
+----------------+
| sha1(null) |
+----------------+
| NULL |
+----------------+
1 row in set (0.00 sec)
```
