©SQL :: Manager
HomeProgram InformationTechnical detailsFree downloadDonate for a cup of coffee
This website works better with Javascript
The MyWAY SQL Manager can be downloaded here for free: as PHP installation file as GZIP file as ZIP archive
If the download from this page does not work, you can also download the program here (Virus checked at heise.de).
By downloading you accept the General Terms and Conditions
The program MyWAY SQL-Manager only works with Javascript
myway SQL Manager for MySQL and MariaDB, Download on Uptodown
SQL functionMySQLMariaDB

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

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

The SHA() 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 SHA() 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 SHA function

 1
 2
 3
 4
 5
 6
 7

select sha('Test');
select sha(123456);

select sha('');
select sha(null);

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

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

Both MySQL and MariaDB provide the SHA() 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.
SECONDSESSION_USERSETVALSHASHA1SHA2SIGN

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

SHA1SHA1(String)
More about SHA1 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 SHA SQL function: mysql.com and mariadb.com
Updated: 2025-11-04ImprintContactTerms & conditionsPrivacy & CookiesUpdatesSitemapFacebookLinkedin©2020-2025 Heino Cunze-Fischer