©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

The SHA1 SQL Function in MySQL and MariaDB - SHA-1 160-bit checksum

SHA1Syntax:SHA1(String)
Return value:CHAR
Synonyms:SHA
Function type:Encryption & Compression
Function Description

The SHA1() function calculates a SHA-1 160-bit checksum for the "String" as described in RFC 3174 (Secure Hash Algorithm).

The value is returned as a string of 40 hexadecimal digits.

Numeric values ​​as an argument are interpreted as a character string.

If the value of the "String" argument is NULL, the SHA1() function returns NULL.


As of MariaDB version 5.5, the return value is a string in the character set and collation of the current connection.

Before MariaDB version 5.5, the function returns a binary string.

SQL Examples for the SHA1 function

 1
 2
 3
 4
 5
 6
 7

select sha1('Test');
select sha1(123456);

select sha1('');
select sha1(null);

sha1('Test')
varchar(40) BINARY
640ab2bae07bedc4c163f679a746f7ab7fb5d1fa
sha1(123456)
varchar(40) BINARY
7c4a8d09ca3762af61e59520943dc26494f8941b
sha1('')
varchar(40) BINARY
da39a3ee5e6b4b0d3255bfef95601890afd80709
sha1(null)
varchar(40) BINARY
NULL
The examples were created with the MyWAY SQL manager: Download

How to use the SHA1() function in MySQL and MariaDB databases

MySQL and MariaDB provide the SHA1() function, which calculates the SHA-1 hash of a given string to obtain a hash value for a specific string of characters, for example for storing hashed passwords, verifying data integrity or for digital signatures.

The SHA-1 is considered a weak hashing algorithm and is no longer recommended for secure hashing purposes. For example, SHA2() function can be used to compute the SHA-256 or SHA-512 hash of a string.
SESSION_USERSETVALSHASHA1SHA2SIGNSIN

Further MySQL und MariaDB SQL Encryption & Compression

AES_DECRYPTAES_DECRYPT(String, Key)
More about AES_DECRYPT Function

AES_ENCRYPTAES_ENCRYPT(String, Key)
More about AES_ENCRYPT Function

COMPRESSCOMPRESS(String)
More about COMPRESS Function

DECODEDECODE(Binary string, Password)
More about DECODE Function

DES_DECRYPTDES_DECRYPT(Binary string [, Key])
More about DES_DECRYPT Function

DES_ENCRYPTDES_ENCRYPT(String [, Key])
More about DES_ENCRYPT Function

ENCODEENCODE(String, Password)
More about ENCODE Function

ENCRYPTENCRYPT(String [, Salt])
More about ENCRYPT Function

FROM_BASE64FROM_BASE64(String)
More about FROM_BASE64 Function

MD5MD5(String)
More about MD5 Function

OLD_PASSWORDOLD_PASSWORD(String)
More about OLD_PASSWORD Function

PASSWORDPASSWORD(String)
More about PASSWORD Function

RANDOM_BYTESRANDOM_BYTES(Length)
More about RANDOM_BYTES Function

SHASHA(String)
More about SHA Function

SHA2SHA2(String, Length)
More about SHA2 Function

TO_BASE64TO_BASE64(String)
More about TO_BASE64 Function

UNCOMPRESSUNCOMPRESS(Binary string)
More about UNCOMPRESS Function

Numeric functionsString functionsRegular ExpressionsDate and Time functions
Comparison functionsEncryption & CompressionConversion functionsNULL functions
Aggregate functionsWindow functionsJSON functionsGeometric functions
Sequence functionsInformation functionsDynamic ColumnsMiscellaneous functions
More information about the SHA1 SQL function: mysql.com and mariadb.com
Updated: 2023-09-24ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedinTwitterStatistics©2020-2024 Heino Cunze-Fischer