Computes the hash of aSTRINGorBYTESvalue, using the SHA-512 algorithm.
FARM_FINGERPRINT
FARM_FINGERPRINT(value)
Description
Computes the fingerprint of theSTRINGorBYTESinput using theFingerprint64function from theopen-source FarmHash library. The output
of this function for a particular input will never change.
Return type
INT64
Examples
WITHexampleAS(SELECT1ASx,"foo"ASy,trueASzUNIONALLSELECT2ASx,"apple"ASy,falseASzUNIONALLSELECT3ASx,""ASy,trueASz)SELECT*,FARM_FINGERPRINT(CONCAT(CAST(xASSTRING),y,CAST(zASSTRING)))ASrow_fingerprintFROMexample;/*---+-------+-------+----------------------*| x | y | z | row_fingerprint |+---+-------+-------+----------------------+| 1 | foo | true | -1541654101129638711 || 2 | apple | false | 2794438866806483259 || 3 | | true | -4880158226897771312 |*---+-------+-------+----------------------*/
MD5
MD5(input)
Description
Computes the hash of the input using theMD5 algorithm. The input can either beSTRINGorBYTES. The string version treats the input as an array of bytes.
This function returns 16 bytes.
Return type
BYTES
Example
SELECTMD5("Hello World")asmd5;-- Note that the result of MD5 is of type BYTES, displayed as a base64-encoded string./*--------------------------*| md5 |+--------------------------+| sQqNsWTgdUEFt6mb5y4/5Q== |*--------------------------*/
SHA1
SHA1(input)
Description
Computes the hash of the input using theSHA-1 algorithm. The input can either beSTRINGorBYTES. The string version treats the input as an array of bytes.
This function returns 20 bytes.
Return type
BYTES
Example
SELECTSHA1("Hello World")assha1;-- Note that the result of SHA1 is of type BYTES, displayed as a base64-encoded string./*------------------------------*| sha1 |+------------------------------+| Ck1VqNd45QIvq3AZd8XYQLvEhtA= |*------------------------------*/
SHA256
SHA256(input)
Description
Computes the hash of the input using theSHA-256 algorithm. The input can either beSTRINGorBYTES. The string version treats the input as an array of bytes.
This function returns 32 bytes.
Return type
BYTES
Example
SELECTSHA256("Hello World")assha256;
SHA512
SHA512(input)
Description
Computes the hash of the input using theSHA-512 algorithm. The input can either beSTRINGorBYTES. The string version treats the input as an array of bytes.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[[["\u003cp\u003eGoogleSQL for BigQuery offers five hash functions: \u003ccode\u003eFARM_FINGERPRINT\u003c/code\u003e, \u003ccode\u003eMD5\u003c/code\u003e, \u003ccode\u003eSHA1\u003c/code\u003e, \u003ccode\u003eSHA256\u003c/code\u003e, and \u003ccode\u003eSHA512\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eFARM_FINGERPRINT\u003c/code\u003e computes a fingerprint of a \u003ccode\u003eSTRING\u003c/code\u003e or \u003ccode\u003eBYTES\u003c/code\u003e value using the FarmHash Fingerprint64 algorithm, returning an \u003ccode\u003eINT64\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMD5\u003c/code\u003e, \u003ccode\u003eSHA1\u003c/code\u003e, \u003ccode\u003eSHA256\u003c/code\u003e, and \u003ccode\u003eSHA512\u003c/code\u003e compute hashes of \u003ccode\u003eSTRING\u003c/code\u003e or \u003ccode\u003eBYTES\u003c/code\u003e values, with \u003ccode\u003eMD5\u003c/code\u003e returning 16 bytes, \u003ccode\u003eSHA1\u003c/code\u003e returning 20 bytes, \u003ccode\u003eSHA256\u003c/code\u003e returning 32 bytes, and \u003ccode\u003eSHA512\u003c/code\u003e returning 64 bytes as \u003ccode\u003eBYTES\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eMD5\u003c/code\u003e and \u003ccode\u003eSHA1\u003c/code\u003e are noted as no longer secure, and it is advised that another hash function should be used for increased security.\u003c/p\u003e\n"]]],[],null,["# Hash functions\n\nGoogleSQL for BigQuery supports the following hash functions.\n\nFunction list\n-------------\n\n`FARM_FINGERPRINT`\n------------------\n\n FARM_FINGERPRINT(value)\n\n**Description**\n\nComputes the fingerprint of the `STRING` or `BYTES` input using the\n`Fingerprint64` function from the\n[open-source FarmHash library](https://github.com/google/farmhash). The output\nof this function for a particular input will never change.\n\n**Return type**\n\nINT64\n\n**Examples** \n\n WITH example AS (\n SELECT 1 AS x, \"foo\" AS y, true AS z UNION ALL\n SELECT 2 AS x, \"apple\" AS y, false AS z UNION ALL\n SELECT 3 AS x, \"\" AS y, true AS z\n )\n SELECT\n *,\n FARM_FINGERPRINT(CONCAT(CAST(x AS STRING), y, CAST(z AS STRING)))\n AS row_fingerprint\n FROM example;\n /*---+-------+-------+----------------------*\n | x | y | z | row_fingerprint |\n +---+-------+-------+----------------------+\n | 1 | foo | true | -1541654101129638711 |\n | 2 | apple | false | 2794438866806483259 |\n | 3 | | true | -4880158226897771312 |\n *---+-------+-------+----------------------*/\n\n`MD5`\n-----\n\n MD5(input)\n\n**Description**\n\nComputes the hash of the input using the\n[MD5 algorithm](https://en.wikipedia.org/wiki/MD5). The input can either be\n`STRING` or `BYTES`. The string version treats the input as an array of bytes.\n\nThis function returns 16 bytes.\n| **Warning:** MD5 is no longer considered secure. For increased security use another hashing function.\n\n**Return type**\n\n`BYTES`\n\n**Example** \n\n SELECT MD5(\"Hello World\") as md5;\n\n -- Note that the result of MD5 is of type BYTES, displayed as a base64-encoded string.\n /*--------------------------*\n | md5 |\n +--------------------------+\n | sQqNsWTgdUEFt6mb5y4/5Q== |\n *--------------------------*/\n\n`SHA1`\n------\n\n SHA1(input)\n\n**Description**\n\nComputes the hash of the input using the\n[SHA-1 algorithm](https://en.wikipedia.org/wiki/SHA-1). The input can either be\n`STRING` or `BYTES`. The string version treats the input as an array of bytes.\n\nThis function returns 20 bytes.\n| **Warning:** SHA1 is no longer considered secure. For increased security, use another hashing function.\n\n**Return type**\n\n`BYTES`\n\n**Example** \n\n SELECT SHA1(\"Hello World\") as sha1;\n\n -- Note that the result of SHA1 is of type BYTES, displayed as a base64-encoded string.\n /*------------------------------*\n | sha1 |\n +------------------------------+\n | Ck1VqNd45QIvq3AZd8XYQLvEhtA= |\n *------------------------------*/\n\n`SHA256`\n--------\n\n SHA256(input)\n\n**Description**\n\nComputes the hash of the input using the\n[SHA-256 algorithm](https://en.wikipedia.org/wiki/SHA-2). The input can either be\n`STRING` or `BYTES`. The string version treats the input as an array of bytes.\n\nThis function returns 32 bytes.\n\n**Return type**\n\n`BYTES`\n\n**Example** \n\n SELECT SHA256(\"Hello World\") as sha256;\n\n`SHA512`\n--------\n\n SHA512(input)\n\n**Description**\n\nComputes the hash of the input using the\n[SHA-512 algorithm](https://en.wikipedia.org/wiki/SHA-2). The input can either be\n`STRING` or `BYTES`. The string version treats the input as an array of bytes.\n\nThis function returns 64 bytes.\n\n**Return type**\n\n`BYTES`\n\n**Example** \n\n SELECT SHA512(\"Hello World\") as sha512;"]]