You don't actually need a UDF to do this. Snowflake supports an encrypt and a decrypt function with a private key. (Technically, this example shows a private passphrase that's converted into a private key. It does support direct key specification too though; read on):
select encrypt('Hello, world.', '531daa2aec446116'); -- Displays as binary jibberish.
select hex_encode(encrypt('Hello, world.', '531daa2aec446116')); -- Displays as HEX. Convert to hex to store as either binary or string.
create temporary table ENCRYPTED_TABLE(COL1 binary, COL2 string);
insert into ENCRYPTED_TABLE select hex_encode(encrypt('Hello, world.', '531daa2aec446116')), hex_encode(encrypt('Hello, world.', '531daa2aec446116'));
select decrypt(COL1, '531daa2aec446116'), decrypt(hex_decode_binary(COL2), '531daa2aec446116') from ENCRYPTED_TABLE;
If you're looking for a way to decrypt values that another system encrypted, the decrypt functions may or may not work. Snowflake's encrypt and decrypt functions use symmetrical encryption with the AES256 cipher. If the source cipher is AES-256, you may get decrypt to work. If the source cipher is anything else, it won't. You'd probably want to try the ENCRYPT_RAW function, which accepts a key rather than dealing with the complexity of how to turn a passphrase into a key.
https://docs.snowflake.com/en/sql-reference/functions/encrypt.html