- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Atbash cipher in Python
Suppose we have a lowercase alphabet string called text. We have to find a new string where every character in text is mapped to its reverse in the alphabet. As an example, a becomes z, b becomes y and so on.
So, if the input is like "abcdefg", then the output will be "zyxwvut"
To solve this, we will follow these steps −
N := ASCII of ('z') + ASCII of ('a')
return ans by joining each character from ASCII value (N - ASCII of s) for each character s in text
Let us see the following implementation to get better understanding −
class Solution: def solve(self, text): N = ord('z') + ord('a') ans='' return ans.join([chr(N - ord(s)) for s in text]) ob = Solution() print(ob.solve("abcdefg")) print(ob.solve("hello"))
- Caesar Cipher in Python
- Difference between Block Cipher and Stream Cipher
- Difference between Monoalphabetic Cipher and Polyalphabetic Cipher
- XOR Cipher in C++
- Difference between Substitution Cipher Technique and Transposition Cipher Technique
- Polybius Square Cipher in C++
- Program to encrypt a string using Vertical Cipher in Python
- Program to encrypt a string using Vigenere cipher in Python
- What is the comparison between Stream Cipher and Block Cipher in information security?
- What is Block Cipher in information security?
- What is Stream Cipher in Information Security?
- What is Monoalphabetic Cipher in Information Security?
- C++ Program to Implement Affine Cipher
- What is a Feistel Cipher in Information Security?