All Products
Search
Document Center

MaxCompute:NEW_KEYSET

Last Updated:Mar 26, 2026

Creates a keyset using the specified algorithm type.

Syntax

binary NEW_KEYSET(string <key_type>, [string <description>])

Parameters

ParameterRequiredDescription
key_typeYesThe algorithm type for the data key in the new keyset. Valid values: AES-GCM-256, AES-SIV-CMAC-128, AES-SIV-CMAC-256.
descriptionNoA description of the data key in the new keyset.

Return value

Returns a keyset of the BINARY type.

Note

Use HEX to convert a BINARY value to STRING, or UNHEX to convert a STRING value back to BINARY.

Example

The following example creates a keyset using the AES-GCM-256 algorithm and converts the result to a readable hex string:

SELECT HEX(NEW_KEYSET('AES-GCM-256', 'hello world'));

Output:

+------------+
| _c0        |
+------------+
| 0A10577567735A514541554D42776E684C4212580A330A0B4145532D47434D2D323536122017F7A430B9D4B59B55454FD4B486216059F1B748CE0502D901EBEACEAB6569191801200210011A10577567735A514541554D42776E684C4220022A0B68656C6C6F20776F726C64 |
+------------+

Related functions

FunctionDescription
Use keysetsHow to use keyset-related encryption and decryption functions.
ADD_KEY_TO_KEYSETAdds a key to a keyset and sets it as the master key.
KEYSET_TO_JSONConverts a BINARY keyset to a readable JSON string.
KEYSET_FROM_JSONConverts a JSON keyset to the BINARY type.
ROTATE_KEYSETGenerates a new key and sets it as the master key.
NEW_WRAPPED_KEYSETCreates a wrapped keyset using a Key Management Service (KMS) customer master key (CMK).
ROTATE_WRAPPED_KEYSETDecrypts a wrapped keyset, rotates the key, and re-encrypts it.
USE_WRAPPED_KEYSETConverts a wrapped keyset to a basic keyset for use in encryption or decryption functions.
ENHANCED_SYM_ENCRYPTEncrypts data using a specified keyset.
ENHANCED_SYM_DECRYPTDecrypts data using a specified keyset.