Forum Discussion

mohammedjs12's avatar
mohammedjs12
New Contributor
2 years ago
Solved

Decrypt a column and load it to Snowflake table

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)
  • 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.

3 Replies

  • 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.

    • Aleksandar_A's avatar
      Aleksandar_A
      Contributor III

      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!