cancel
Showing results for 
Search instead for 
Did you mean: 

Decrypt a column and load it to Snowflake table

mohammedjs12
New Contributor

Hi Team,

I have a requirement where i need to decrypt a column coming from a snowflake table. Column value present in source table is already in encrypted form. 

I used below approaches but none actually worked.

1. Create a java file with decrypt functionality. Used script snap to call this java file but the snap throws an error.

2. Created a python script with decrypt functionality. Used script snap to call this java file but the snap throws an error.

Please help me find a solution for this.

Python script used:

def decrypt_caesar_cipher(ciphertext, shift)
plaintext=''
for char in ciphertext:
if char.isalpha():
shifted_char = chr(((ord(char.lower()) - ord('a') - shift) %26) + ord('a'))
plaintext += shifted_char if char.islower() else shifted_char.upper()
else:
plaintext += char
return plaintext
 
s=decrypt_caesar_cipher('ciphertext', 1)
print(s)
1 ACCEPTED SOLUTION

AleksandarAngel
Contributor III

Hello @mohammedjs12,

Attached below is a sample pipeline implementing Caesar Cipher in a Script Snap using Python.

You will have to structure the input and the output according to your requirements.

Please let me know if this helps you!

Regards,

Aleksandar.

View solution in original post

3 REPLIES 3

AleksandarAngel
Contributor III

Hello @mohammedjs12,

Attached below is a sample pipeline implementing Caesar Cipher in a Script Snap using Python.

You will have to structure the input and the output according to your requirements.

Please let me know if this helps you!

Regards,

Aleksandar.

Also, you can try this in a Mapper Snap with the following expression:

sl.range(0,$ciphertext.length).map(x => $ciphertext.charCodeAt(x)).map(x => ((x >= 65 && x <= 90) || (x>= 97 && x<= 122)) ? String.fromCharCode(x - $shift) : String.fromCharCode(x)).join("")

Please let me know if this helps you!

Thanks a ton!!