TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of Hill cipher algorithm. More...
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
#include "../numerical_methods/lu_decomposition.h"
Go to the source code of this file.
Classes | |
class | ciphers::HillCipher |
Implementation of Hill Cipher algorithm. More... | |
Namespaces | |
namespace | ciphers |
Algorithms for encryption and decryption. | |
Functions | |
template<typename T > | |
static std::ostream & | operator<< (std::ostream &out, matrix< T > const &v) |
void | test1 (const std::string &text) |
Self test 1 - using 3x3 randomly generated key. | |
void | test2 (const std::string &text) |
Self test 2 - using 8x8 randomly generated key. | |
int | main () |
Variables | |
static const char * | ciphers::STRKEY |
Implementation of Hill cipher algorithm.
Program to generate the encryption-decryption key and perform encryption and decryption of ASCII text using the famous block cipher algorithm. This is a powerful encryption algorithm that is relatively easy to implement with a given key. The strength of the algorithm depends on the size of the block encryption matrix key; the bigger the matrix, the stronger the encryption and more difficult to break it. However, the important requirement for the matrix is that:
In the current implementation, I present to you an implementation for generating larger encryption keys (I have attempted upto 10x10) and an ASCII character set of 97 printable characters. Hence, a typical ASCII text file could be easily encrypted with the module. The larger character set increases the modulo of cipher and hence the matrix determinants can get very large very quickly rendering them ill-defined.
Definition in file hill_cipher.cpp.
int main | ( | void | ) |
Main function
Definition at line 533 of file hill_cipher.cpp.
|
static |
operator to print a matrix
Definition at line 55 of file hill_cipher.cpp.
void test1 | ( | const std::string & | text | ) |
Self test 1 - using 3x3 randomly generated key.
text | string to encrypt and decrypt |
Definition at line 471 of file hill_cipher.cpp.
void test2 | ( | const std::string & | text | ) |
Self test 2 - using 8x8 randomly generated key.
text | string to encrypt and decrypt |
Definition at line 506 of file hill_cipher.cpp.