projekty
/
krypto.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e6c0c57
)
index koincidence pro kratke zpravy
nmail
author
Tomas Musil
<tomik.musil@gmail.com>
Tue, 4 Jun 2013 16:26:21 +0000
(18:26 +0200)
committer
Tomas Musil
<tomik.musil@gmail.com>
Tue, 4 Jun 2013 16:26:21 +0000
(18:26 +0200)
koincidence.py
patch
|
blob
|
history
krypto.py
patch
|
blob
|
history
diff --git
a/koincidence.py
b/koincidence.py
index
5c943ec
..
f49174b
100644
(file)
--- a/
koincidence.py
+++ b/
koincidence.py
@@
-32,8
+32,9
@@
def index_rozkladu(text, deleni):
def tabulka_indexu(text):
"""Vypise tabulku prumernych indexu pro ruzna deleni textu."""
def tabulka_indexu(text):
"""Vypise tabulku prumernych indexu pro ruzna deleni textu."""
+ n = min((len(text)/3), 11)
return '\n'.join(['{1:>2} {0:>7.3%}'.format(
return '\n'.join(['{1:>2} {0:>7.3%}'.format(
- index_rozkladu(text, d), d) for d in range(1,
11
)])
+ index_rozkladu(text, d), d) for d in range(1,
n
)])
def rozklad(text, deleni):
"""Vrati pole retezcu, v kazdem jsou znaky z puvodniho textu jejichz pozice
def rozklad(text, deleni):
"""Vrati pole retezcu, v kazdem jsou znaky z puvodniho textu jejichz pozice
diff --git
a/krypto.py
b/krypto.py
index
c0ed935
..
392e8ba
100755
(executable)
--- a/
krypto.py
+++ b/
krypto.py
@@
-67,11
+67,12
@@
def analyza(zprava, opsny):
analyza.append("\nIndex koincidence (s mezerami):")
analyza.append('{0:.2%}'.format(
koincidence.index_koincidence(zprava, True)))
analyza.append("\nIndex koincidence (s mezerami):")
analyza.append('{0:.2%}'.format(
koincidence.index_koincidence(zprava, True)))
- if mod_x
and len(zprava) >= 30
:
+ if mod_x:
#TODO tady by se spravne mela porovnavat delka ocesane zpravy
analyza.append("\nIndexy koincidence (bez mezer):")
analyza.append(koincidence.tabulka_indexu(zprava))
#TODO tady by se spravne mela porovnavat delka ocesane zpravy
analyza.append("\nIndexy koincidence (bez mezer):")
analyza.append(koincidence.tabulka_indexu(zprava))
+
# Vigenere
if 'V' in opsny:
analyza.append("\nHeslo k Vigenerovi (" + opsny[-1] + "):")
# Vigenere
if 'V' in opsny:
analyza.append("\nHeslo k Vigenerovi (" + opsny[-1] + "):")