How to encrypt VARCHAR or BINARY in Snowflake ? What are the Encryption Functions in Snowflake ?

Snowflake

In Snowflake Encryption functions encrypt or decrypt VARCHAR or BINARY values.

ENCRYPT : This function will Encrypts a VARCHAR or BINARY value using a VARCHAR passphrase.
Syntax

ENCRYPT( <value_to_encrypt> , <passphrase> ,[ [ <additional_authenticated_data> , ] <encryption_method> ])

value_to_encrypt : The VARCHAR or BINARY value to encrypt.
passphrase : The passphrase to use to encrypt/decrypt the data. The passphrase will always be a VARCHAR, regardless of whether the value_to_encrypt is VARCHAR or BINARY.
additional_authenticated_data : Additional authenticated data (AAD) is additional data whose confidentiality and authenticity is assured during the decryption process.
encryption_method : This string will specifies the method to use for encrypting/decrypting the data.

Example

select encrypt('wlCoMe2!', 'Testpassphrase');
set passphrase='urg!23@@Ok32Fgrde';
select to_varchar(decrypt(encrypt('President will be on Offical Visit on Jan 2023 ', $passphrase),$passphrase),'utf-8' as dcrypt ;
Author: user

Leave a Reply