# Python Script to decrypt a column

**URL:** <https://discuss.python.org/t/python-script-to-decrypt-a-column/46427>\
**Category:** Python Help\
**Created:** [February 20, 2024, 2:08pm UTC](https://discuss.python.org/t/python-script-to-decrypt-a-column/46427 "2024-02-20T14:08:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohammedjs](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@mohammedjs](https://discuss.python.org/u/mohammedjs)\
**Post date:** [February 20, 2024, 2:08pm UTC](https://discuss.python.org/t/python-script-to-decrypt-a-column/46427/1 "2024-02-20T14:08:04Z")

</div>

Hi Team,

I need to create python script to decrypt sample input data to get appropriate out. Can anyone please assist. (First column in sample is in encrypted form and needs to be decrypted as below )

**Input sample data:**  
9173810AB115CF3F037F4CCE642E8549,05-JUN-19,16-JAN-24

**Expected output**  
233945335,05-JUN-19,16-JAN-24

I am trying to use below logic but its not working as expected.

**pythons script**  
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)

---

<div class="post-metadata">

**Author:** ![DerSchinken](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/derschinken/32/15648_2.png) [@DerSchinken](https://discuss.python.org/u/DerSchinken)\
**Post date:** [February 20, 2024, 2:26pm UTC](https://discuss.python.org/t/python-script-to-decrypt-a-column/46427/2 "2024-02-20T14:26:22Z")

</div>

> [@mohammedjs](#):
>
> 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)

Please put the code in a code block see [this markdown tutorial](https://www.jetbrains.com/help/hub/markdown-syntax.html#fenced-code-blocks). And please add the output you are currently getting with your function

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [February 20, 2024, 2:33pm UTC](https://discuss.python.org/t/python-script-to-decrypt-a-column/46427/3 "2024-02-20T14:33:58Z")

</div>

A string encoded with a Caesar cipher should be the same length as the original string, which is the case with your function, but the input is clearly longer than the output, and it doesn’t look like a Caesar cipher anyway.

---

<div class="post-metadata">

**Author:** ![DerSchinken](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/derschinken/32/15648_2.png) [@DerSchinken](https://discuss.python.org/u/DerSchinken)\
**Post date:** [February 20, 2024, 3:14pm UTC](https://discuss.python.org/t/python-script-to-decrypt-a-column/46427/6 "2024-02-20T15:14:30Z")

</div>

Sorry my mind is cooked right now I just can’t think straight 🫠

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [February 20, 2024, 4:05pm UTC](https://discuss.python.org/t/python-script-to-decrypt-a-column/46427/7 "2024-02-20T16:05:23Z")

</div>

> [@mohammedjs](#):
>
> 9173810AB115CF3F037F4CCE642E8549

This is 32 digits of hexadecimal, or 128 bits of data. It could be a block of AES-encrypted data, or an MD5 hash of the data, or something like that.
