Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions caesar/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ def answer(self):
key = 0 # variable to store the key

# your algorithm
data = open(chiper.data, "r")
Ascii = range(128)


data = open(chiper.ciphertext, "r")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manggilnya chiphertextnya jangan kayak gini

Ascii = 127
key = 127 - 81

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dapet dari mana 127 - 81?

word = data.read()
translate = ""
for x in word:
code = 0
code = ord(str(x)) - key
if (code < 0):
code += Ascii
translate += chr(code)
print(translate)
data.close()
return (key)

# add methods if you need more


chiper = Caesar()
ans = chiper.answer()

Expand Down