Advertisement
Guest User

ceasar cypher fr word brutforce

a guest
Aug 3rd, 2012
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. """Brut force d'un chiffre de césar sur un mot (assisté par dictionnaire).
  5. Le fichier liste.de.mots.francais.frgut.txt est accessible librement sur le net. Il doit être placé dans le répertoire d'exécution.
  6. (sous licence WTFPL: http://sam.zoy.org/wtfpl/).
  7.  
  8. 03/08/2012, by Ginko."""
  9.  
  10. import sys, string
  11.  
  12. text = sys.argv[1]
  13. abc = string.ascii_lowercase
  14.  
  15. def import_dico():
  16.     dico = []
  17.     with open('liste.de.mots.francais.frgut.txt', 'r') as f:
  18.         for line in f:
  19.             dico.append(line.rstrip('\n'))
  20.     return dico
  21.  
  22. mots_fr = import_dico()
  23.  
  24. def shift_table():
  25.     """Generator that shift the table."""
  26.     for i in range(26):
  27.         yield "".join((abc[i:], abc[:i]))
  28.  
  29. for a in shift_table():
  30.     trans = text.translate(string.maketrans(abc, a))
  31.     if trans in mots_fr: print trans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement