Massive fix for afine -> affine typo.

This commit is contained in:
Glenn Y. Rolland 2012-08-15 01:26:24 +02:00
parent 5319941786
commit 7caee47c91
54 changed files with 176 additions and 176 deletions

View file

@ -3,7 +3,7 @@ demodir = demo
demo_DATA = \ demo_DATA = \
demo/vigenere.txt \ demo/vigenere.txt \
demo/afine.txt \ demo/affine.txt \
demo/plaintext.txt \ demo/plaintext.txt \
demo/vigenere.2.txt \ demo/vigenere.2.txt \
demo/vigenere.3.txt demo/vigenere.3.txt

View file

@ -3,7 +3,7 @@
## 1. Description ## 1. Description
CryptAffinity est un logiciel libre permettant de déchiffrer des texte 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 : caractéristiques suivantes :
* Il est distribue sous la licence [GNU General Public License](http://www.gnu.org/copyleft/gpl.html) * 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 : Pour utiliser le décodeur Affine :
break_affinity -a data/alphabet.txt -f 0.7 -m a -p data/priority.txt \ 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 : Pour utiliser le décodeur Vigenère :
@ -148,7 +148,7 @@ en entrée:
int alpha_size; //taille de l'alphabet int alpha_size; //taille de l'alphabet
std::list<int> orb; // nombre premiers avec alpha_size std::list<int> orb; // nombre premiers avec alpha_size
MathTools mt; // bibliotheque d'outils mathematiques MathTools mt; // bibliotheque d'outils mathematiques
std::list<KeyAfine> keyList; std::list<KeyAffine> keyList;
std::list<int>::iterator orbIt; std::list<int>::iterator orbIt;
for (i=1; i<alpha_size; i++){ for (i=1; i<alpha_size; i++){
@ -158,7 +158,7 @@ en entrée:
} }
// 1 - generer l'espace des 312 clefs // 1 - generer l'espace des 312 clefs
for (orbIt = orb.begin(); orbIt != orb.end(); orbIt++){ for (orbIt = orb.begin(); orbIt != orb.end(); orbIt++){
KeyAfine key; KeyAffine key;
key.setCoefA((*orbIt)); key.setCoefA((*orbIt));
for (i=0; i<alpha_size; i++){ for (i=0; i<alpha_size; i++){
key.setCoefB(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 float frequencies; // frequence cumulee des 9 lettres les
plus presentes plus presentes
float epsilon; // marge d'erreur float epsilon; // marge d'erreur
std::list<KeyAfine>::iterator kLIt; std::list<KeyAffine>::iterator kLIt;
for (kLIt = keyList.begin(); kLIt != keyList.end(); kLIt++){ for (kLIt = keyList.begin(); kLIt != keyList.end(); kLIt++){
float score = 0; float score = 0;

View file

@ -16,21 +16,21 @@ dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dnl dnl
## Autoconf requirements ## Autoconf requirements
AC_INIT([CryptAfinity], [0.2], [glenux@fr.st]) AC_INIT([CryptAffinity], [0.2], [glenux@glenux.net])
AC_PREREQ(2.50) AC_PREREQ(2.50)
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([CryptAfinity],[0.2]) AM_INIT_AUTOMAKE([CryptAffinity],[0.2])
#AC_CANONICAL_SYSTEM #AC_CANONICAL_SYSTEM
AM_CONFIG_HEADER(src/config.h) AM_CONFIG_HEADER(src/config.h)
AC_CONFIG_SRCDIR([src/lib/cryptafinity.hh]) AC_CONFIG_SRCDIR([src/lib/cryptaffinity.hh])
AC_PROG_INSTALL AC_PROG_INSTALL
## information on the package ## information on the package

View file

@ -1,37 +1,37 @@
SUBDIRS = . SUBDIRS = .
lib_LTLIBRARIES = libcryptafinity.la lib_LTLIBRARIES = libcryptaffinity.la
#bin_PROGRAMS = libulm.o #bin_PROGRAMS = libulm.o
libcryptafinity_la_SOURCES = alphabet.cpp \ libcryptaffinity_la_SOURCES = alphabet.cpp \
key.cpp \ key.cpp \
text.cpp \ text.cpp \
codec.cpp \ codec.cpp \
letter.cpp \ letter.cpp \
codec_afine.cpp \ codec_affine.cpp \
codec_vigenere.cpp \ codec_vigenere.cpp \
key_afine.cpp \ key_affine.cpp \
key_vigenere.cpp \ key_vigenere.cpp \
word_list.cpp \ word_list.cpp \
math_tools.cpp \ math_tools.cpp \
freq_analyser.cpp freq_analyser.cpp
#libcryptafinity_la_SOURCES += cryptafinity_errors.hh \ #libcryptaffinity_la_SOURCES += cryptaffinity_errors.hh \
# cryptafinity_global.hh \ # cryptaffinity_global.hh \
# cryptafinity.hh \ # cryptaffinity.hh \
# cryptafinity_iface.hh \ # cryptaffinity_iface.hh \
# cryptafinity_proto.hh \ # cryptaffinity_proto.hh \
# XSock.hh # XSock.hh
libcryptafinity_la_CFLAGS = -DTRACE -static libcryptaffinity_la_CFLAGS = -DTRACE -static
libcryptafinity_la_LDFLAGS = -version-info 3:12:1 libcryptaffinity_la_LDFLAGS = -version-info 3:12:1
#INCLUDES= SQLITE3_CFLAGS@ \ #INCLUDES= SQLITE3_CFLAGS@ \
# LIBXMLPP_CFLAGS@ \ # LIBXMLPP_CFLAGS@ \
# -I./ # -I./
#libcryptafinity_a_LDFLAGS= @LDFLAGS@ #libcryptaffinity_a_LDFLAGS= @LDFLAGS@
#SQLITE3_LIBS@ LIBPCRE_LIBS@ #SQLITE3_LIBS@ LIBPCRE_LIBS@

View file

@ -1,7 +1,7 @@
#include "alphabet.hh" #include "alphabet.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
Alphabet::Alphabet() : std::vector<std::string>() { } Alphabet::Alphabet() : std::vector<std::string>() { }

View file

@ -1,11 +1,11 @@
#ifndef _LIBCRYPAFINITY_ALPHABET_HH #ifndef _LIBCRYPAFFINITY_ALPHABET_HH
#define _LIBCRYPAFINITY_ALPHABET_HH #define _LIBCRYPAFFINITY_ALPHABET_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class ReverseAlphabet: public std::map<std::string, int> { class ReverseAlphabet: public std::map<std::string, int> {
}; };

View file

@ -1,7 +1,7 @@
#include "codec.hh" #include "codec.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
Codec::Codec(){ Codec::Codec(){
} }

View file

@ -1,13 +1,13 @@
#ifndef _LIBCRYPAFINITY_CODEC_HH #ifndef _LIBCRYPAFFINITY_CODEC_HH
#define _LIBCRYPAFINITY_CODEC_HH #define _LIBCRYPAFFINITY_CODEC_HH
#include "text.hh" #include "text.hh"
#include "key.hh" #include "key.hh"
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class Codec { class Codec {
private: private:
public: public:

View file

@ -1,8 +1,8 @@
#include "codec_afine.hh" #include "codec_affine.hh"
#include "math_tools.hh" #include "math_tools.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
CodecAfine::CodecAfine() : Codec() { CodecAfine::CodecAfine() : Codec() {
} }

23
src/lib/codec_affine.hh Normal file
View 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

View file

@ -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

View file

@ -1,7 +1,7 @@
#include "codec_vigenere.hh" #include "codec_vigenere.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
CodecVigenere::CodecVigenere() : Codec() { CodecVigenere::CodecVigenere() : Codec() {
} }

View file

@ -1,14 +1,14 @@
#ifndef _LIBCRYPAFINITY_CODEC_VIGENERE_HH #ifndef _LIBCRYPAFFINITY_CODEC_VIGENERE_HH
#define _LIBCRYPAFINITY_CODEC_VIGENERE_HH #define _LIBCRYPAFFINITY_CODEC_VIGENERE_HH
#include "codec.hh" #include "codec.hh"
#include "key_vigenere.hh" #include "key_vigenere.hh"
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class CodecVigenere : public Codec { class CodecVigenere : public Codec {
private: private:
public: public:

8
src/lib/cryptaffinity.hh Normal file
View file

@ -0,0 +1,8 @@
#ifndef _CRYPTAFFINITY_HH
#define _CRYPTAFFINITY_HH
#include "cryptaffinity_global.hh"
#include "cryptaffinity_iface.hh"
#include "cryptaffinity_proto.hh"
#endif

View file

@ -1,5 +1,5 @@
#ifndef _CRYPTAFINITY_GLOBAL_HH #ifndef _CRYPTAFFINITY_GLOBAL_HH
#define _CRYPTAFINITY_GLOBAL_HH #define _CRYPTAFFINITY_GLOBAL_HH
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>

View file

@ -0,0 +1,4 @@
#ifndef _CRYPTAFFINITY_IFACE_HH
#define _CRYPTAFFINITY_IFACE_HH
#endif

View file

@ -1,5 +1,5 @@
#ifndef _CRYPTAFINITY_PROTO_HH #ifndef _CRYPTAFFINITY_PROTO_HH
#define _CRYPTAFINITY_PROTO_HH #define _CRYPTAFFINITY_PROTO_HH
#include "math_tools.hh" #include "math_tools.hh"
#include "alphabet.hh" #include "alphabet.hh"
@ -9,6 +9,6 @@
#include "freq_analyser.hh" #include "freq_analyser.hh"
#include "codec.hh" #include "codec.hh"
#include "codec_vigenere.hh" #include "codec_vigenere.hh"
#include "codec_afine.hh" #include "codec_affine.hh"
#endif #endif

View file

@ -1,8 +0,0 @@
#ifndef _CRYPTAFINITY_HH
#define _CRYPTAFINITY_HH
#include "cryptafinity_global.hh"
#include "cryptafinity_iface.hh"
#include "cryptafinity_proto.hh"
#endif

View file

@ -1,4 +0,0 @@
#ifndef _CRYPTAFINITY_IFACE_HH
#define _CRYPTAFINITY_IFACE_HH
#endif

View file

@ -4,7 +4,7 @@
#define DEBUG 0 #define DEBUG 0
namespace LibCryptAfinity { namespace LibCryptAffinity {
std::list<TextCounter> FreqAnalyser::getPriorities(Text text, int keylen, int column){ std::list<TextCounter> FreqAnalyser::getPriorities(Text text, int keylen, int column){
std::list<TextCounter> result; std::list<TextCounter> result;
std::map<Text, int> counter; std::map<Text, int> counter;

View file

@ -1,12 +1,12 @@
#ifndef _LIBCRYPTAFINITY_FREQANALYSER_HH #ifndef _LIBCRYPTAFFINITY_FREQANALYSER_HH
#define _LIBCRYPTAFINITY_FREQANALYSER_HH #define _LIBCRYPTAFFINITY_FREQANALYSER_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
#include "text.hh" // body #include "text.hh" // body
namespace LibCryptAfinity { namespace LibCryptAffinity {
class FreqAnalyser { class FreqAnalyser {
private: private:

View file

@ -1,7 +1,7 @@
#include "key.hh" #include "key.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
Key::Key() { } Key::Key() { }
// std::string Key::toString() { } // std::string Key::toString() { }

View file

@ -4,10 +4,10 @@
//#include "text.hh" //#include "text.hh"
//#include "cryptafinity_global.hh" //#include "cryptaffinity_global.hh"
//#include "cryptafinity_iface.hh" //#include "cryptaffinity_iface.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class Key { class Key {
private: private:
public: public:

View file

@ -1,10 +1,10 @@
#include "key_afine.hh" #include "key_affine.hh"
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
int KeyAfine::getCoefA(){ int KeyAfine::getCoefA(){
return this->_a; return this->_a;

View file

@ -1,13 +1,13 @@
#ifndef _CRYPTAFINIY_KEYAFINE_HH #ifndef _CRYPTAFINIY_KEYAFINE_HH
#define _CRYPTAFINIY_KEYAFINE_HH #define _CRYPTAFINIY_KEYAFINE_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
#include "key.hh" // declaration #include "key.hh" // declaration
#include "text.hh" // body #include "text.hh" // body
namespace LibCryptAfinity { namespace LibCryptAffinity {
class KeyAfine : public Key { class KeyAfine : public Key {
private: private:
int _a; int _a;

View file

@ -1,7 +1,7 @@
#include "key_vigenere.hh" #include "key_vigenere.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
KeyVigenere::KeyVigenere() : Key(), Text() { // Key() KeyVigenere::KeyVigenere() : Key(), Text() { // Key()
int i; int i;
i=0; i=0;

View file

@ -1,13 +1,13 @@
#ifndef _CRYPTAFINIY_KEYVIGENERE_HH #ifndef _CRYPTAFINIY_KEYVIGENERE_HH
#define _CRYPTAFINIY_KEYVIGENERE_HH #define _CRYPTAFINIY_KEYVIGENERE_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
#include "text.hh" #include "text.hh"
#include "key.hh" #include "key.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class KeyVigenere : public Key, public Text { class KeyVigenere : public Key, public Text {
private: private:
public: public:

View file

@ -1,6 +1,6 @@
#include "letter.hh" #include "letter.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
Letter::Letter(const Letter &orig){ Letter::Letter(const Letter &orig){
this->_alphabet = orig._alphabet; this->_alphabet = orig._alphabet;

View file

@ -1,12 +1,12 @@
#ifndef _LIBCRYPTAFINITY_LETTER_HH #ifndef _LIBCRYPTAFFINITY_LETTER_HH
#define _LIBCRYPTAFINITY_LETTER_HH #define _LIBCRYPTAFFINITY_LETTER_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
#include "alphabet.hh" #include "alphabet.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class Letter { class Letter {
private: private:
Alphabet _alphabet; Alphabet _alphabet;

View file

@ -3,7 +3,7 @@
#define DEBUG 1 #define DEBUG 1
namespace LibCryptAfinity { namespace LibCryptAffinity {
int MathTools::pgcd(int a, int b){ int MathTools::pgcd(int a, int b){
int fa = a; int fa = a;

View file

@ -1,10 +1,10 @@
#ifndef _LIBCRYPTAFINITY_MATHTOOLS_HH #ifndef _LIBCRYPTAFFINITY_MATHTOOLS_HH
#define _LIBCRYPTAFINITY_MATHTOOLS_HH #define _LIBCRYPTAFFINITY_MATHTOOLS_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class MathTools { class MathTools {
private: private:

View file

@ -2,7 +2,7 @@
#include "text.hh" #include "text.hh"
#define DEBUG 0 #define DEBUG 0
namespace LibCryptAfinity { namespace LibCryptAffinity {
bool TextCounter::operator< (TextCounter b){ bool TextCounter::operator< (TextCounter b){
fflush(stdout); fflush(stdout);
if (this->_text.size() < b.getText().size()){ if (this->_text.size() < b.getText().size()){

View file

@ -1,12 +1,12 @@
#ifndef _LIBCRYPAFINITY_TEXT_HH #ifndef _LIBCRYPAFFINITY_TEXT_HH
#define _LIBCRYPAFINITY_TEXT_HH #define _LIBCRYPAFFINITY_TEXT_HH
#include "cryptafinity_global.hh" #include "cryptaffinity_global.hh"
#include "cryptafinity_iface.hh" #include "cryptaffinity_iface.hh"
#include "alphabet.hh" #include "alphabet.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class TextCounter; class TextCounter;
class Text : public std::vector<int> { class Text : public std::vector<int> {

View file

@ -1,7 +1,7 @@
#include "word_list.hh" #include "word_list.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
std::map<Text,int> WordList::getWordsContaining(int value){ std::map<Text,int> WordList::getWordsContaining(int value){
std::map<Text,int> result; std::map<Text,int> result;
std::map<int, TextCounter>::iterator foundVal; std::map<int, TextCounter>::iterator foundVal;

View file

@ -4,7 +4,7 @@
#include <map> #include <map>
#include "text.hh" #include "text.hh"
namespace LibCryptAfinity { namespace LibCryptAffinity {
class WordList { class WordList {
private: private:
std::map<Text, int> _word2int; // existance du mot std::map<Text, int> _word2int; // existance du mot

View file

@ -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

View file

@ -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

View file

@ -2,10 +2,10 @@
SUBDIRS = . 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.cpp \
# ftp_client_cmd.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 \ # miniftp.cpp \
# server_msg.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 \ # ftp_config.hh \
# miniftp_global.hh \ # miniftp_global.hh \
@ -32,6 +32,6 @@ INCLUDES= -I../lib/ -I./ @GLIB2_CFLAGS@
# libyalag.la # libyalag.la
# miniftpc_INCLUDE = a # miniftpc_INCLUDE = a
break_afinity_LDADD = -lcryptafinity @GLIB2_LIBS@ break_affinity_LDADD = -lcryptaffinity @GLIB2_LIBS@
break_afinity_LDFLAGS = @LDFLAGS@ -L../lib -L../lib/.libs break_affinity_LDFLAGS = @LDFLAGS@ -L../lib -L../lib/.libs

View file

@ -4,9 +4,9 @@
#define DEBUG 1 #define DEBUG 1
namespace BreakAfinity { namespace BreakAffinity {
void BreakAfinity::runAfine(){ void BreakAffinity::runAfine(){
MathTools mt; MathTools mt;
CodecAfine codec; CodecAfine codec;
FreqAnalyser fa; FreqAnalyser fa;

View file

@ -4,20 +4,20 @@
#define DEBUG 0 #define DEBUG 0
namespace BreakAfinity { namespace BreakAffinity {
BreakAfinity::BreakAfinity(){ BreakAffinity::BreakAffinity(){
// on fixe la config par defaut // on fixe la config par defaut
int i; int i;
i=i+1; i=i+1;
} }
void BreakAfinity::loadFiles(){ void BreakAffinity::loadFiles(){
printf("ALIVE !!!\n"); printf("ALIVE !!!\n");
this->_config.loadFiles(); this->_config.loadFiles();
printf("ALIVE ???\n"); printf("ALIVE ???\n");
} }
void BreakAfinity::init(int argc, char **argv) { void BreakAffinity::init(int argc, char **argv) {
int i; int i;
for (i = 1; i + 1 < argc; i = i + 2){ 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("-a, --alphabet <file> Letters ordered by decreasing frequency\n");
printf("-e, --epsilon <float> Tolerance for the final key test\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("-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("-p, --priorities <file> Letters ordered by decreasing frequency\n");
printf("-t, --text <file> Cipher text to decipher\n"); printf("-t, --text <file> Cipher text to decipher\n");
//printf("-s, --popsize <int> Population size in each generation\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 ? // vigenere ou affine ?
MathTools mt; MathTools mt;
CodecVigenere codec; CodecVigenere codec;

View file

@ -1,20 +1,20 @@
#ifndef _BREAKAFINITY_CMD_HH #ifndef _BREAKAFFINITY_CMD_HH
#define _BREAKAFINITY_CMD_HH #define _BREAKAFFINITY_CMD_HH
#include <string.h> #include <string.h>
#include <list> #include <list>
#include "breakafinity.hh" #include "breakaffinity.hh"
#include "ba_config.hh" #include "ba_config.hh"
namespace BreakAfinity { namespace BreakAffinity {
class BreakAfinity { class BreakAffinity {
private: private:
BreakerConfig _config; BreakerConfig _config;
public: public:
BreakAfinity(); BreakAffinity();
void init(int argc, char ** argv); void init(int argc, char ** argv);
void loadFiles(); void loadFiles();
void run(); void run();

View file

@ -2,7 +2,7 @@
#include "ba_config.hh" #include "ba_config.hh"
#include "file_loader.hh" #include "file_loader.hh"
namespace BreakAfinity { namespace BreakAffinity {
void BreakerConfig::setMode(char * m){ void BreakerConfig::setMode(char * m){
switch(m[0]){ switch(m[0]){
case 'v': case 'v':

View file

@ -1,5 +1,5 @@
#ifndef _BREAKAFINITY_CONFIG_HH #ifndef _BREAKAFFINITY_CONFIG_HH
#define _BREAKAFINITY_CONFIG_HH #define _BREAKAFFINITY_CONFIG_HH
#include <string> #include <string>
#include <vector> #include <vector>
@ -8,9 +8,9 @@
#include "alphabet.hh" #include "alphabet.hh"
#include "text.hh" #include "text.hh"
using namespace LibCryptAfinity; using namespace LibCryptAffinity;
namespace BreakAfinity { namespace BreakAffinity {
class BreakerConfig { class BreakerConfig {
private: private:
bool _modeVigenere; bool _modeVigenere;

View file

@ -4,9 +4,9 @@
#define DEBUG 0 #define DEBUG 0
namespace BreakAfinity { namespace BreakAffinity {
void BreakAfinity::runVigenere(){ void BreakAffinity::runVigenere(){
MathTools mt; MathTools mt;
CodecVigenere codec; CodecVigenere codec;
FreqAnalyser fa; FreqAnalyser fa;
@ -17,7 +17,7 @@ namespace BreakAfinity {
int alpha_size = this->_config.getAlphabet().size(); int alpha_size = this->_config.getAlphabet().size();
// 1 - repérer les mots qui se répentent // 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; KeyVigenere key;
TextCounter fst; TextCounter fst;
TextCounter sec; TextCounter sec;
@ -49,7 +49,7 @@ namespace BreakAfinity {
// 2 - on en déduit la longueur de la clef // 2 - on en déduit la longueur de la clef
key_len = mt.pgcd(dist1,dist2); 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 // 3 - on calcule le décalage par colonne
std::list<TextCounter>::iterator pI; std::list<TextCounter>::iterator pI;

View file

@ -0,0 +1,8 @@
#ifndef _BREAKAFFINITY_HH
#define _BREAKAFFINITY_HH
#include "breakaffinity_global.hh"
#include "breakaffinity_iface.hh"
#include "breakaffinity_proto.hh"
#endif

View file

@ -1,10 +1,10 @@
#ifndef _BREAKAFINITY_GLOBAL_HH #ifndef _BREAKAFFINITY_GLOBAL_HH
#define _BREAKAFINITY_GLOBAL_HH #define _BREAKAFFINITY_GLOBAL_HH
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "cryptafinity.hh" #include "cryptaffinity.hh"
#define COLOR_GREEN "\x1B[33m" #define COLOR_GREEN "\x1B[33m"
#define COLOR_NORMAL "\x1B[0m" #define COLOR_NORMAL "\x1B[0m"

View file

@ -0,0 +1,4 @@
#ifndef _BREAKAFFINITY_IFACE_HH
#define _BREAKAFFINITY_IFACE_HH
#endif

View file

@ -1,5 +1,5 @@
#ifndef _BREAKAFINITY_PROTO_HH #ifndef _BREAKAFFINITY_PROTO_HH
#define _BREAKAFINITY_PROTO_HH #define _BREAKAFFINITY_PROTO_HH
#include "ba_cmd.hh" #include "ba_cmd.hh"
#include "ba_config.hh" #include "ba_config.hh"

View file

@ -1,8 +0,0 @@
#ifndef _BREAKAFINITY_HH
#define _BREAKAFINITY_HH
#include "breakafinity_global.hh"
#include "breakafinity_iface.hh"
#include "breakafinity_proto.hh"
#endif

View file

@ -1,4 +0,0 @@
#ifndef _BREAKAFINITY_IFACE_HH
#define _BREAKAFINITY_IFACE_HH
#endif

View file

@ -1,9 +1,9 @@
#include "file_loader.hh" #include "file_loader.hh"
using namespace LibCryptAfinity; using namespace LibCryptAffinity;
namespace BreakAfinity { namespace BreakAffinity {
std::vector<int> FileLoader::loadPriorities( std::vector<int> FileLoader::loadPriorities(
std::map<std::string, int> reverse_alpha, std::map<std::string, int> reverse_alpha,
std::string filename){ std::string filename){

View file

@ -10,9 +10,9 @@
#include "alphabet.hh" #include "alphabet.hh"
#include "text.hh" #include "text.hh"
using namespace LibCryptAfinity; using namespace LibCryptAffinity;
namespace BreakAfinity{ namespace BreakAffinity{
class FileLoader { class FileLoader {
private: private:
public: public:

View file

@ -1,11 +1,11 @@
#include "breakafinity.hh" #include "breakaffinity.hh"
#include "ba_cmd.hh" #include "ba_cmd.hh"
using namespace BreakAfinity; using namespace BreakAffinity;
int main(int argc, char ** argv){ int main(int argc, char ** argv){
::BreakAfinity::BreakAfinity br_af; ::BreakAffinity::BreakAffinity br_af;
br_af.init(argc, argv); br_af.init(argc, argv);
br_af.loadFiles(); br_af.loadFiles();