Massive fix for afine -> affine typo.
This commit is contained in:
parent
5319941786
commit
7caee47c91
54 changed files with 176 additions and 176 deletions
|
@ -3,7 +3,7 @@ demodir = demo
|
|||
|
||||
demo_DATA = \
|
||||
demo/vigenere.txt \
|
||||
demo/afine.txt \
|
||||
demo/affine.txt \
|
||||
demo/plaintext.txt \
|
||||
demo/vigenere.2.txt \
|
||||
demo/vigenere.3.txt
|
||||
|
|
10
README.md
10
README.md
|
@ -3,7 +3,7 @@
|
|||
## 1. Description
|
||||
|
||||
CryptAffinity est un logiciel libre permettant de déchiffrer des texte
|
||||
obfusqués par des systemes Afines ou l'algorithme de Vigenère. Il possède les
|
||||
obfusqués par des systemes Affines ou l'algorithme de Vigenère. Il possède les
|
||||
caractéristiques suivantes :
|
||||
|
||||
* Il est distribue sous la licence [GNU General Public License](http://www.gnu.org/copyleft/gpl.html)
|
||||
|
@ -120,7 +120,7 @@ clair.
|
|||
Pour utiliser le décodeur Affine :
|
||||
|
||||
break_affinity -a data/alphabet.txt -f 0.7 -m a -p data/priority.txt \
|
||||
-t demo/afine.txt -e 0.1
|
||||
-t demo/affine.txt -e 0.1
|
||||
|
||||
Pour utiliser le décodeur Vigenère :
|
||||
|
||||
|
@ -148,7 +148,7 @@ en entrée:
|
|||
int alpha_size; //taille de l'alphabet
|
||||
std::list<int> orb; // nombre premiers avec alpha_size
|
||||
MathTools mt; // bibliotheque d'outils mathematiques
|
||||
std::list<KeyAfine> keyList;
|
||||
std::list<KeyAffine> keyList;
|
||||
std::list<int>::iterator orbIt;
|
||||
|
||||
for (i=1; i<alpha_size; i++){
|
||||
|
@ -158,7 +158,7 @@ en entrée:
|
|||
}
|
||||
// 1 - generer l'espace des 312 clefs
|
||||
for (orbIt = orb.begin(); orbIt != orb.end(); orbIt++){
|
||||
KeyAfine key;
|
||||
KeyAffine key;
|
||||
key.setCoefA((*orbIt));
|
||||
for (i=0; i<alpha_size; i++){
|
||||
key.setCoefB(i);
|
||||
|
@ -173,7 +173,7 @@ Puis on fait une attaque par analyse de frequence sur les textes obtenus par
|
|||
float frequencies; // frequence cumulee des 9 lettres les
|
||||
plus presentes
|
||||
float epsilon; // marge d'erreur
|
||||
std::list<KeyAfine>::iterator kLIt;
|
||||
std::list<KeyAffine>::iterator kLIt;
|
||||
|
||||
for (kLIt = keyList.begin(); kLIt != keyList.end(); kLIt++){
|
||||
float score = 0;
|
||||
|
|
|
@ -16,21 +16,21 @@ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
dnl
|
||||
|
||||
## Autoconf requirements
|
||||
AC_INIT([CryptAfinity], [0.2], [glenux@fr.st])
|
||||
AC_INIT([CryptAffinity], [0.2], [glenux@glenux.net])
|
||||
AC_PREREQ(2.50)
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
|
||||
AM_INIT_AUTOMAKE([CryptAfinity],[0.2])
|
||||
AM_INIT_AUTOMAKE([CryptAffinity],[0.2])
|
||||
|
||||
#AC_CANONICAL_SYSTEM
|
||||
|
||||
|
||||
|
||||
AM_CONFIG_HEADER(src/config.h)
|
||||
AC_CONFIG_SRCDIR([src/lib/cryptafinity.hh])
|
||||
AC_CONFIG_SRCDIR([src/lib/cryptaffinity.hh])
|
||||
AC_PROG_INSTALL
|
||||
|
||||
## information on the package
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
SUBDIRS = .
|
||||
|
||||
lib_LTLIBRARIES = libcryptafinity.la
|
||||
lib_LTLIBRARIES = libcryptaffinity.la
|
||||
|
||||
#bin_PROGRAMS = libulm.o
|
||||
|
||||
libcryptafinity_la_SOURCES = alphabet.cpp \
|
||||
libcryptaffinity_la_SOURCES = alphabet.cpp \
|
||||
key.cpp \
|
||||
text.cpp \
|
||||
codec.cpp \
|
||||
letter.cpp \
|
||||
codec_afine.cpp \
|
||||
codec_affine.cpp \
|
||||
codec_vigenere.cpp \
|
||||
key_afine.cpp \
|
||||
key_affine.cpp \
|
||||
key_vigenere.cpp \
|
||||
word_list.cpp \
|
||||
math_tools.cpp \
|
||||
freq_analyser.cpp
|
||||
|
||||
#libcryptafinity_la_SOURCES += cryptafinity_errors.hh \
|
||||
# cryptafinity_global.hh \
|
||||
# cryptafinity.hh \
|
||||
# cryptafinity_iface.hh \
|
||||
# cryptafinity_proto.hh \
|
||||
#libcryptaffinity_la_SOURCES += cryptaffinity_errors.hh \
|
||||
# cryptaffinity_global.hh \
|
||||
# cryptaffinity.hh \
|
||||
# cryptaffinity_iface.hh \
|
||||
# cryptaffinity_proto.hh \
|
||||
# XSock.hh
|
||||
|
||||
libcryptafinity_la_CFLAGS = -DTRACE -static
|
||||
libcryptafinity_la_LDFLAGS = -version-info 3:12:1
|
||||
libcryptaffinity_la_CFLAGS = -DTRACE -static
|
||||
libcryptaffinity_la_LDFLAGS = -version-info 3:12:1
|
||||
|
||||
#INCLUDES= SQLITE3_CFLAGS@ \
|
||||
# LIBXMLPP_CFLAGS@ \
|
||||
# -I./
|
||||
|
||||
#libcryptafinity_a_LDFLAGS= @LDFLAGS@
|
||||
#libcryptaffinity_a_LDFLAGS= @LDFLAGS@
|
||||
|
||||
#SQLITE3_LIBS@ LIBPCRE_LIBS@
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "alphabet.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
|
||||
Alphabet::Alphabet() : std::vector<std::string>() { }
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef _LIBCRYPAFINITY_ALPHABET_HH
|
||||
#define _LIBCRYPAFINITY_ALPHABET_HH
|
||||
#ifndef _LIBCRYPAFFINITY_ALPHABET_HH
|
||||
#define _LIBCRYPAFFINITY_ALPHABET_HH
|
||||
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class ReverseAlphabet: public std::map<std::string, int> {
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "codec.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
Codec::Codec(){
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#ifndef _LIBCRYPAFINITY_CODEC_HH
|
||||
#define _LIBCRYPAFINITY_CODEC_HH
|
||||
#ifndef _LIBCRYPAFFINITY_CODEC_HH
|
||||
#define _LIBCRYPAFFINITY_CODEC_HH
|
||||
|
||||
|
||||
#include "text.hh"
|
||||
#include "key.hh"
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class Codec {
|
||||
private:
|
||||
public:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
#include "codec_afine.hh"
|
||||
#include "codec_affine.hh"
|
||||
#include "math_tools.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
CodecAfine::CodecAfine() : Codec() {
|
||||
}
|
||||
|
23
src/lib/codec_affine.hh
Normal file
23
src/lib/codec_affine.hh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef _LIBCRYPAFFINITY_CODEC_AFINE_HH
|
||||
#define _LIBCRYPAFFINITY_CODEC_AFINE_HH
|
||||
|
||||
#include "codec.hh"
|
||||
#include "key_affine.hh"
|
||||
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
|
||||
namespace LibCryptAffinity {
|
||||
class CodecAfine : public Codec {
|
||||
private:
|
||||
public:
|
||||
CodecAfine();
|
||||
|
||||
Text encode(Text t, KeyAfine k);
|
||||
Text decode(Text t, KeyAfine k);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef _LIBCRYPAFINITY_CODEC_AFINE_HH
|
||||
#define _LIBCRYPAFINITY_CODEC_AFINE_HH
|
||||
|
||||
#include "codec.hh"
|
||||
#include "key_afine.hh"
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
class CodecAfine : public Codec {
|
||||
private:
|
||||
public:
|
||||
CodecAfine();
|
||||
|
||||
Text encode(Text t, KeyAfine k);
|
||||
Text decode(Text t, KeyAfine k);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "codec_vigenere.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
CodecVigenere::CodecVigenere() : Codec() {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#ifndef _LIBCRYPAFINITY_CODEC_VIGENERE_HH
|
||||
#define _LIBCRYPAFINITY_CODEC_VIGENERE_HH
|
||||
#ifndef _LIBCRYPAFFINITY_CODEC_VIGENERE_HH
|
||||
#define _LIBCRYPAFFINITY_CODEC_VIGENERE_HH
|
||||
|
||||
#include "codec.hh"
|
||||
#include "key_vigenere.hh"
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class CodecVigenere : public Codec {
|
||||
private:
|
||||
public:
|
||||
|
|
8
src/lib/cryptaffinity.hh
Normal file
8
src/lib/cryptaffinity.hh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef _CRYPTAFFINITY_HH
|
||||
#define _CRYPTAFFINITY_HH
|
||||
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
#include "cryptaffinity_proto.hh"
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _CRYPTAFINITY_GLOBAL_HH
|
||||
#define _CRYPTAFINITY_GLOBAL_HH
|
||||
#ifndef _CRYPTAFFINITY_GLOBAL_HH
|
||||
#define _CRYPTAFFINITY_GLOBAL_HH
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
4
src/lib/cryptaffinity_iface.hh
Normal file
4
src/lib/cryptaffinity_iface.hh
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef _CRYPTAFFINITY_IFACE_HH
|
||||
#define _CRYPTAFFINITY_IFACE_HH
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _CRYPTAFINITY_PROTO_HH
|
||||
#define _CRYPTAFINITY_PROTO_HH
|
||||
#ifndef _CRYPTAFFINITY_PROTO_HH
|
||||
#define _CRYPTAFFINITY_PROTO_HH
|
||||
|
||||
#include "math_tools.hh"
|
||||
#include "alphabet.hh"
|
||||
|
@ -9,6 +9,6 @@
|
|||
#include "freq_analyser.hh"
|
||||
#include "codec.hh"
|
||||
#include "codec_vigenere.hh"
|
||||
#include "codec_afine.hh"
|
||||
#include "codec_affine.hh"
|
||||
|
||||
#endif
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef _CRYPTAFINITY_HH
|
||||
#define _CRYPTAFINITY_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptafinity_proto.hh"
|
||||
|
||||
#endif
|
|
@ -1,4 +0,0 @@
|
|||
#ifndef _CRYPTAFINITY_IFACE_HH
|
||||
#define _CRYPTAFINITY_IFACE_HH
|
||||
|
||||
#endif
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#define DEBUG 0
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
std::list<TextCounter> FreqAnalyser::getPriorities(Text text, int keylen, int column){
|
||||
std::list<TextCounter> result;
|
||||
std::map<Text, int> counter;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef _LIBCRYPTAFINITY_FREQANALYSER_HH
|
||||
#define _LIBCRYPTAFINITY_FREQANALYSER_HH
|
||||
#ifndef _LIBCRYPTAFFINITY_FREQANALYSER_HH
|
||||
#define _LIBCRYPTAFFINITY_FREQANALYSER_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
#include "text.hh" // body
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
|
||||
class FreqAnalyser {
|
||||
private:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "key.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
Key::Key() { }
|
||||
|
||||
// std::string Key::toString() { }
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
//#include "text.hh"
|
||||
|
||||
//#include "cryptafinity_global.hh"
|
||||
//#include "cryptafinity_iface.hh"
|
||||
//#include "cryptaffinity_global.hh"
|
||||
//#include "cryptaffinity_iface.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class Key {
|
||||
private:
|
||||
public:
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
|
||||
#include "key_afine.hh"
|
||||
#include "key_affine.hh"
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
|
||||
int KeyAfine::getCoefA(){
|
||||
return this->_a;
|
|
@ -1,13 +1,13 @@
|
|||
#ifndef _CRYPTAFINIY_KEYAFINE_HH
|
||||
#define _CRYPTAFINIY_KEYAFINE_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
#include "key.hh" // declaration
|
||||
#include "text.hh" // body
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class KeyAfine : public Key {
|
||||
private:
|
||||
int _a;
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "key_vigenere.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
KeyVigenere::KeyVigenere() : Key(), Text() { // Key()
|
||||
int i;
|
||||
i=0;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#ifndef _CRYPTAFINIY_KEYVIGENERE_HH
|
||||
#define _CRYPTAFINIY_KEYVIGENERE_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
#include "text.hh"
|
||||
#include "key.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class KeyVigenere : public Key, public Text {
|
||||
private:
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "letter.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
|
||||
Letter::Letter(const Letter &orig){
|
||||
this->_alphabet = orig._alphabet;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef _LIBCRYPTAFINITY_LETTER_HH
|
||||
#define _LIBCRYPTAFINITY_LETTER_HH
|
||||
#ifndef _LIBCRYPTAFFINITY_LETTER_HH
|
||||
#define _LIBCRYPTAFFINITY_LETTER_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
#include "alphabet.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class Letter {
|
||||
private:
|
||||
Alphabet _alphabet;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#define DEBUG 1
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
|
||||
int MathTools::pgcd(int a, int b){
|
||||
int fa = a;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _LIBCRYPTAFINITY_MATHTOOLS_HH
|
||||
#define _LIBCRYPTAFINITY_MATHTOOLS_HH
|
||||
#ifndef _LIBCRYPTAFFINITY_MATHTOOLS_HH
|
||||
#define _LIBCRYPTAFFINITY_MATHTOOLS_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
|
||||
class MathTools {
|
||||
private:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "text.hh"
|
||||
|
||||
#define DEBUG 0
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
bool TextCounter::operator< (TextCounter b){
|
||||
fflush(stdout);
|
||||
if (this->_text.size() < b.getText().size()){
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef _LIBCRYPAFINITY_TEXT_HH
|
||||
#define _LIBCRYPAFINITY_TEXT_HH
|
||||
#ifndef _LIBCRYPAFFINITY_TEXT_HH
|
||||
#define _LIBCRYPAFFINITY_TEXT_HH
|
||||
|
||||
#include "cryptafinity_global.hh"
|
||||
#include "cryptafinity_iface.hh"
|
||||
#include "cryptaffinity_global.hh"
|
||||
#include "cryptaffinity_iface.hh"
|
||||
|
||||
#include "alphabet.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class TextCounter;
|
||||
|
||||
class Text : public std::vector<int> {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "word_list.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
std::map<Text,int> WordList::getWordsContaining(int value){
|
||||
std::map<Text,int> result;
|
||||
std::map<int, TextCounter>::iterator foundVal;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <map>
|
||||
#include "text.hh"
|
||||
|
||||
namespace LibCryptAfinity {
|
||||
namespace LibCryptAffinity {
|
||||
class WordList {
|
||||
private:
|
||||
std::map<Text, int> _word2int; // existance du mot
|
||||
|
|
|
@ -1 +1 @@
|
|||
./tools/break_afinity -a tests/alphabet.txt -f 0.7 -m a -p tests/priority.txt -t tests/afine.txt -e 0.1
|
||||
./tools/break_affinity -a data/alphabet.txt -f 0.7 -m a -p data/priority.txt -t demo/affine.txt -e 0.1
|
||||
|
|
|
@ -1 +1 @@
|
|||
./tools/break_afinity -a tests/alphabet.txt -f 0.7 -m v -p tests/priority.txt -t tests/vigenere.txt -e 0.05
|
||||
./tools/break_affinity -a data/alphabet.txt -f 0.7 -m v -p data/priority.txt -t demo/vigenere.txt -e 0.05
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
SUBDIRS = .
|
||||
|
||||
bin_PROGRAMS = break_afinity
|
||||
bin_PROGRAMS = break_affinity
|
||||
|
||||
|
||||
break_afinity_SOURCES = main.cpp ba_cmd.cpp ba_config.cpp file_loader.cpp ba_vigenere.cpp ba_afine.cpp
|
||||
break_affinity_SOURCES = main.cpp ba_cmd.cpp ba_config.cpp file_loader.cpp ba_vigenere.cpp ba_affine.cpp
|
||||
|
||||
# ftp_client.cpp \
|
||||
# ftp_client_cmd.cpp \
|
||||
|
@ -13,7 +13,7 @@ break_afinity_SOURCES = main.cpp ba_cmd.cpp ba_config.cpp file_loader.cpp ba_vi
|
|||
# miniftp.cpp \
|
||||
# server_msg.cpp
|
||||
|
||||
break_afinity_SOURCES += ba_cmd.hh breakafinity.hh breakafinity_global.hh breakafinity_iface.hh breakafinity_proto.hh file_loader.hh
|
||||
break_affinity_SOURCES += ba_cmd.hh breakaffinity.hh breakaffinity_global.hh breakaffinity_iface.hh breakaffinity_proto.hh file_loader.hh
|
||||
|
||||
# ftp_config.hh \
|
||||
# miniftp_global.hh \
|
||||
|
@ -32,6 +32,6 @@ INCLUDES= -I../lib/ -I./ @GLIB2_CFLAGS@
|
|||
# libyalag.la
|
||||
# miniftpc_INCLUDE = a
|
||||
|
||||
break_afinity_LDADD = -lcryptafinity @GLIB2_LIBS@
|
||||
break_afinity_LDFLAGS = @LDFLAGS@ -L../lib -L../lib/.libs
|
||||
break_affinity_LDADD = -lcryptaffinity @GLIB2_LIBS@
|
||||
break_affinity_LDFLAGS = @LDFLAGS@ -L../lib -L../lib/.libs
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#define DEBUG 1
|
||||
|
||||
namespace BreakAfinity {
|
||||
namespace BreakAffinity {
|
||||
|
||||
void BreakAfinity::runAfine(){
|
||||
void BreakAffinity::runAfine(){
|
||||
MathTools mt;
|
||||
CodecAfine codec;
|
||||
FreqAnalyser fa;
|
|
@ -4,20 +4,20 @@
|
|||
|
||||
#define DEBUG 0
|
||||
|
||||
namespace BreakAfinity {
|
||||
BreakAfinity::BreakAfinity(){
|
||||
namespace BreakAffinity {
|
||||
BreakAffinity::BreakAffinity(){
|
||||
// on fixe la config par defaut
|
||||
int i;
|
||||
i=i+1;
|
||||
}
|
||||
|
||||
void BreakAfinity::loadFiles(){
|
||||
void BreakAffinity::loadFiles(){
|
||||
printf("ALIVE !!!\n");
|
||||
this->_config.loadFiles();
|
||||
printf("ALIVE ???\n");
|
||||
}
|
||||
|
||||
void BreakAfinity::init(int argc, char **argv) {
|
||||
void BreakAffinity::init(int argc, char **argv) {
|
||||
int i;
|
||||
|
||||
for (i = 1; i + 1 < argc; i = i + 2){
|
||||
|
@ -60,7 +60,7 @@ namespace BreakAfinity {
|
|||
printf("-a, --alphabet <file> Letters ordered by decreasing frequency\n");
|
||||
printf("-e, --epsilon <float> Tolerance for the final key test\n");
|
||||
printf("-f, --frequencies <float> Average frequencies for the 9 first letters\n");
|
||||
printf("-m, --mode ( v | a ) Choose the kind of cypher : vigenere or afine.\n");
|
||||
printf("-m, --mode ( v | a ) Choose the kind of cypher : vigenere or affine.\n");
|
||||
printf("-p, --priorities <file> Letters ordered by decreasing frequency\n");
|
||||
printf("-t, --text <file> Cipher text to decipher\n");
|
||||
//printf("-s, --popsize <int> Population size in each generation\n");
|
||||
|
@ -71,7 +71,7 @@ namespace BreakAfinity {
|
|||
}
|
||||
}
|
||||
|
||||
void BreakAfinity::run(){
|
||||
void BreakAffinity::run(){
|
||||
// vigenere ou affine ?
|
||||
MathTools mt;
|
||||
CodecVigenere codec;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#ifndef _BREAKAFINITY_CMD_HH
|
||||
#define _BREAKAFINITY_CMD_HH
|
||||
#ifndef _BREAKAFFINITY_CMD_HH
|
||||
#define _BREAKAFFINITY_CMD_HH
|
||||
|
||||
#include <string.h>
|
||||
#include <list>
|
||||
|
||||
#include "breakafinity.hh"
|
||||
#include "breakaffinity.hh"
|
||||
#include "ba_config.hh"
|
||||
|
||||
|
||||
namespace BreakAfinity {
|
||||
namespace BreakAffinity {
|
||||
|
||||
class BreakAfinity {
|
||||
class BreakAffinity {
|
||||
private:
|
||||
BreakerConfig _config;
|
||||
public:
|
||||
BreakAfinity();
|
||||
BreakAffinity();
|
||||
void init(int argc, char ** argv);
|
||||
void loadFiles();
|
||||
void run();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "ba_config.hh"
|
||||
#include "file_loader.hh"
|
||||
|
||||
namespace BreakAfinity {
|
||||
namespace BreakAffinity {
|
||||
void BreakerConfig::setMode(char * m){
|
||||
switch(m[0]){
|
||||
case 'v':
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _BREAKAFINITY_CONFIG_HH
|
||||
#define _BREAKAFINITY_CONFIG_HH
|
||||
#ifndef _BREAKAFFINITY_CONFIG_HH
|
||||
#define _BREAKAFFINITY_CONFIG_HH
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -8,9 +8,9 @@
|
|||
#include "alphabet.hh"
|
||||
#include "text.hh"
|
||||
|
||||
using namespace LibCryptAfinity;
|
||||
using namespace LibCryptAffinity;
|
||||
|
||||
namespace BreakAfinity {
|
||||
namespace BreakAffinity {
|
||||
class BreakerConfig {
|
||||
private:
|
||||
bool _modeVigenere;
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#define DEBUG 0
|
||||
|
||||
namespace BreakAfinity {
|
||||
namespace BreakAffinity {
|
||||
|
||||
void BreakAfinity::runVigenere(){
|
||||
void BreakAffinity::runVigenere(){
|
||||
MathTools mt;
|
||||
CodecVigenere codec;
|
||||
FreqAnalyser fa;
|
||||
|
@ -17,7 +17,7 @@ namespace BreakAfinity {
|
|||
int alpha_size = this->_config.getAlphabet().size();
|
||||
|
||||
// 1 - repérer les mots qui se répentent
|
||||
pDEBUG("BreakAfinity::run","analysing %s\n",cypherText.toString().c_str());
|
||||
pDEBUG("BreakAffinity::run","analysing %s\n",cypherText.toString().c_str());
|
||||
KeyVigenere key;
|
||||
TextCounter fst;
|
||||
TextCounter sec;
|
||||
|
@ -49,7 +49,7 @@ namespace BreakAfinity {
|
|||
|
||||
// 2 - on en déduit la longueur de la clef
|
||||
key_len = mt.pgcd(dist1,dist2);
|
||||
pDEBUG("BreakAfinity::run","PGCD(%d, %d) = %d\n", dist1, dist2, key_len);
|
||||
pDEBUG("BreakAffinity::run","PGCD(%d, %d) = %d\n", dist1, dist2, key_len);
|
||||
|
||||
// 3 - on calcule le décalage par colonne
|
||||
std::list<TextCounter>::iterator pI;
|
||||
|
|
8
src/tools/breakaffinity.hh
Normal file
8
src/tools/breakaffinity.hh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef _BREAKAFFINITY_HH
|
||||
#define _BREAKAFFINITY_HH
|
||||
|
||||
#include "breakaffinity_global.hh"
|
||||
#include "breakaffinity_iface.hh"
|
||||
#include "breakaffinity_proto.hh"
|
||||
|
||||
#endif
|
|
@ -1,10 +1,10 @@
|
|||
#ifndef _BREAKAFINITY_GLOBAL_HH
|
||||
#define _BREAKAFINITY_GLOBAL_HH
|
||||
#ifndef _BREAKAFFINITY_GLOBAL_HH
|
||||
#define _BREAKAFFINITY_GLOBAL_HH
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "cryptafinity.hh"
|
||||
#include "cryptaffinity.hh"
|
||||
|
||||
#define COLOR_GREEN "\x1B[33m"
|
||||
#define COLOR_NORMAL "\x1B[0m"
|
4
src/tools/breakaffinity_iface.hh
Normal file
4
src/tools/breakaffinity_iface.hh
Normal file
|
@ -0,0 +1,4 @@
|
|||
#ifndef _BREAKAFFINITY_IFACE_HH
|
||||
#define _BREAKAFFINITY_IFACE_HH
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef _BREAKAFINITY_PROTO_HH
|
||||
#define _BREAKAFINITY_PROTO_HH
|
||||
#ifndef _BREAKAFFINITY_PROTO_HH
|
||||
#define _BREAKAFFINITY_PROTO_HH
|
||||
|
||||
#include "ba_cmd.hh"
|
||||
#include "ba_config.hh"
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef _BREAKAFINITY_HH
|
||||
#define _BREAKAFINITY_HH
|
||||
|
||||
#include "breakafinity_global.hh"
|
||||
#include "breakafinity_iface.hh"
|
||||
#include "breakafinity_proto.hh"
|
||||
|
||||
#endif
|
|
@ -1,4 +0,0 @@
|
|||
#ifndef _BREAKAFINITY_IFACE_HH
|
||||
#define _BREAKAFINITY_IFACE_HH
|
||||
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
#include "file_loader.hh"
|
||||
|
||||
using namespace LibCryptAfinity;
|
||||
using namespace LibCryptAffinity;
|
||||
|
||||
namespace BreakAfinity {
|
||||
namespace BreakAffinity {
|
||||
std::vector<int> FileLoader::loadPriorities(
|
||||
std::map<std::string, int> reverse_alpha,
|
||||
std::string filename){
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include "alphabet.hh"
|
||||
#include "text.hh"
|
||||
|
||||
using namespace LibCryptAfinity;
|
||||
using namespace LibCryptAffinity;
|
||||
|
||||
namespace BreakAfinity{
|
||||
namespace BreakAffinity{
|
||||
class FileLoader {
|
||||
private:
|
||||
public:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
#include "breakafinity.hh"
|
||||
#include "breakaffinity.hh"
|
||||
#include "ba_cmd.hh"
|
||||
|
||||
using namespace BreakAfinity;
|
||||
using namespace BreakAffinity;
|
||||
|
||||
int main(int argc, char ** argv){
|
||||
::BreakAfinity::BreakAfinity br_af;
|
||||
::BreakAffinity::BreakAffinity br_af;
|
||||
|
||||
br_af.init(argc, argv);
|
||||
br_af.loadFiles();
|
||||
|
|
Loading…
Reference in a new issue