etao
etao is a simple Python library that assists in the creation of cryptanalysis tools.
Installation
Install with pip:
pip install etao
Example Application
The following is a Caesar cipher solving tool that uses etao’s frequency analysis functions and built-in ciphers.
#!/usr/bin/env python
# Caesar cipher solver
import argparse
import etao
def main():
parser = argparse.ArgumentParser(description="Caesar cipher solver")
parser.add_argument('ciphertext', type=str, help='text to decipher')
args = parser.parse_args()
# Get every Caesar shift of the ciphertext
shifts = [etao.caesar_shift(args.ciphertext, n) for n in range(26)]
# Score each shift according to English character frequency.
# Get tuples that pair the score with the text.
scored_shifts = [(etao.score_text(shift), shift) for shift in shifts]
# Sort by score, descending order
scored_shifts.sort(reverse=True)
# Print the top 3 results
for result in scored_shifts[0:3]:
print '"%s" (%02d%%)' % (result[1], int(result[0] * 100))
if __name__ == "__main__":
main()
Here’s what it looks like in action:
$ ./caesar_solver.py "O GQFSOAWBU QCASG OQFCGG HVS GYM. WH VOG VODDSBSR PSTCFS, PIH HVSFS WG BCHVWBU HC QCADOFS WH HC BCK."
"A SCREAMING COMES ACROSS THE SKY. IT HAS HAPPENED BEFORE, BUT THERE IS NOTHING TO COMPARE IT TO NOW." (95%)
"L DNCPLXTYR NZXPD LNCZDD ESP DVJ. TE SLD SLAAPYPO MPQZCP, MFE ESPCP TD YZESTYR EZ NZXALCP TE EZ YZH." (65%)
"P HRGTPBXCV RDBTH PRGDHH IWT HZN. XI WPH WPEETCTS QTUDGT, QJI IWTGT XH CDIWXCV ID RDBEPGT XI ID CDL." (65%)
Metadata
Release files for etao 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| etao-0.5.0.tar.gz | 21.7 kB | Details |
Release files / etao-0.5.0.tar.gz
| Download URL | etao-0.5.0.tar.gz |
|---|---|
| Size | 21.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2063fd7122a6d5ea63f8c9fd09f8ef0a2a283bf52260de31e30b4ba3245264cc
|
|
BLAKE2b-256 checksum How to use checksums |
72a67158cedccf5e63b3f5d7368bb8f7a93e0841546d3fa2588b4b0c2188c84a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |