tencent cloud

Feedback

Binary Functions

Last updated: 2024-08-07 17:30:56

    CRC32

    Function statement:
    CRC32(<expr> string|binary)
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Compute the cyclic redundancy check value of the expression using the CRC32 algorithm.
    Return type: bigint
    Example:
    > select crc32('tencent');
    820633257

    MD5

    Function statement:
    MD5(<expr string|binary)
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Return the MD5 128-bit checksum as a hexadecimal string.
    Return type: string
    Example:
    > select md5('tencent');
    3da576879001c77b442b9f8ef95c09d6

    HASH

    Function statement:
    HASH(&lt;expr1&gt; any[, &lt;expr2&gt; any, ...])
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Return the hash value of all parameters. The calculation methods in SPARKSQL and PRESTO are inconsistent, so the results may differ.
    Return type: integer
    Example:
    > SELECT hash('tencent', array(123), 2);
    -412995102

    XXHASH64

    Function statement:
    XXHASH64(&lt;expr1&gt; any[, &lt;expr2&gt; any, ...])
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Return the 64-bit hash value of the parameter. The calculation methods in SPARKSQL and PRESTO are inconsistent, so the results may differ.
    Return type: bigint
    Example:
    > SELECT xxhash64('tencent', array(123), 2);
    -1900074178543885261

    SHA

    Function statement:
    SHA(<expr> string|binary)
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Return the SHA-1 hash value of expr as a hexadecimal string.
    Return type: string
    Example:
    > select sha('tencent');
    f94b2c96e2f127726ef4bcec6bc779f0f2e7888f

    SHA1

    Function statement:
    SHA1(<expr> string|binary)
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Return the SHA-1 hash value of expr as a hexadecimal string.
    Return type: string
    Example:
    > select sha1('tencent');
    f94b2c96e2f127726ef4bcec6bc779f0f2e7888f

    SHA2

    Function statement:
    SHA2(expr string|binary, bitLength int)
    Supported engines: SPARKSQL and PRESTO
    Usage instructions: Return the checksum of expr for the SHA-2 family as a hexadecimal string. SHA-224, SHA-256, SHA-384, and SHA-512 are supported. A bit length of 0 equals to 256.
    Return type: string
    Example:
    > select sha2('tencent', 256);
    9c8ae69b84f21a2e46df9edf0063a697afec050188ff2884ddc8ab32b5e58c43

    AES_ENCRYPT

    Function statement:
    AES_ENCRYPT(<expr> string|binary, <key> string|binary)
    Supported engines: PRESTO
    Usage instructions: Encrypt expr using the AES algorithm.
    Return type: binary
    Example:
    > SELECT hex(aes_encrypt('tencent', '0000111122223333'));
    B99B99CE3359A736DBB9811ED8815C01

    AES_DECRYPT

    Function statement:
    AES_DECRYPT(<expr> string|binary, <key> string|binary)
    Supported engine: PRESTO
    Usage instructions: Decrypt expr using the AES algorithm.
    Return type: binary
    Example:
    > SELECT aes_decrypt(unhex('B99B99CE3359A736DBB9811ED8815C01'), '0000111122223333');
    tencent
    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support