vigenere_cipher
"/home/yossef/notes/personal/hashing/vigenere_cipher.md"
path: personal/hashing/vigenere_cipher.md
- **fileName**: vigenere_cipher
- **Created on**: 2025-03-21 00:24:38
-> ((p + k) % 26) this the formal for vigenree cipher encryption
vigenere cipher example ;)
# starting creating a vigenere cipher
def encryption(plain_text: str, key: int) -> str:
"""
function for implementing a encryption for plain text using key
-> ((p + k) % 26) this the formal for encryption
p: is the char after converted to a ascii representation
k: is the key for that adding to text
% 26: to check if out of bounds
"""
encrypt_text = ""
# itration for all char in text
for i in range(len(plain_text)):
## starting by convert the char to number ASCII TABLE
# for more information:
# [[???]]
# why subtraction by a to make a range for x ascii numbers between
# 0 to 26
x = ord(plain_text[i]) - ord('a')
x = (x + key) % 26 # apply formal
encrypt_text += chr(x) # convert ot char
return encrypt_text
def main():
plain_text = "yossef"
print(encryption(plain_text=plain_text, key=8))
if __name__ == "__main__":
main()
continue:./vigenere_cipher2.md
before:./hill_cipher.md