SHA2

MariaDB starting with 5.5.5

SHA2() was introduced in MariaDB 5.5.5

Sintassi

SHA2(str, lunghezza_hash)

Spiegazione

Data una stringa str, calcola il checksum SHA-2, che è considerato crittograficamente più sicuro del suo corrispettivo SHA-1. La famiglia SHA-2 comprende SHA-224, SHA-256, SHA-384, e SHA-512. lunghezza_hash deve corrispondere a uno di essi, cioè il suo valore deve essere 224, 256, 384 o 512. 0 equivale a 256.

NULL viene restituito se lunghezza_hash non è valido, o se str è NULL.

SHA2 funziona solo se MariaDB è stato configurato con il supporto a SSL.

Esempi

SELECT SHA2('Maria',224);
+----------------------------------------------------------+
| SHA2('Maria',224)                                        |
+----------------------------------------------------------+
| 6cc67add32286412efcab9d0e1675a43a5c2ef3cec8879f81516ff83 |
+----------------------------------------------------------+

SELECT SHA2('Maria',256);
+------------------------------------------------------------------+
| SHA2('Maria',256)                                                |
+------------------------------------------------------------------+
| 9ff18ebe7449349f358e3af0b57cf7a032c1c6b2272cb2656ff85eb112232f16 |
+------------------------------------------------------------------+

SELECT SHA2('Maria',0);
+------------------------------------------------------------------+
| SHA2('Maria',0)                                                  |
+------------------------------------------------------------------+
| 9ff18ebe7449349f358e3af0b57cf7a032c1c6b2272cb2656ff85eb112232f16 |
+------------------------------------------------------------------+

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.