Skip to content
This repository was archived by the owner on Nov 11, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b3cabb6
Add deprecated system block diagram
Jun 7, 2018
f8ac1d0
Add deprecated acm
Jun 7, 2018
590a72b
Add deprecated ftie
Jun 7, 2018
0809345
add deprecated main
Jun 8, 2018
ad01e64
Merge branch 'master' into deprecated
Jun 8, 2018
0f8429b
Rename variable and include library
Jun 8, 2018
169cfc7
Merge branch 'master' into deprecated
Jun 9, 2018
c24ed7e
Add histogram experiment and result
Jun 9, 2018
80f64d9
Add npcr experiment
Jun 9, 2018
835cf68
Update npcr output
Jun 9, 2018
ee2fcff
Add entropy experiment
Jun 9, 2018
267a79f
Merge branch 'master' into deprecated
Jun 11, 2018
1ec1e8d
Merge branch 'deprecated' into experiment
Jun 11, 2018
afbc50b
Merge branch 'master' into deprecated
Jun 11, 2018
8e7e385
Merge branch 'deprecated' into experiment
Jun 11, 2018
d682e76
Merge branch 'master' into deprecated
Jun 13, 2018
0e6a33c
Merge branch 'deprecated' into experiment
Jun 13, 2018
1944ee4
Ignore temporary file
Jun 13, 2018
8508634
Merge branch 'master' into deprecated
Jun 17, 2018
b44de9e
Bug in deprecated acm
Jun 17, 2018
1aa7c33
Merge branch 'deprecated' into experiment
Jun 17, 2018
daa01f4
Add time experiment
Jun 17, 2018
d84b292
Add avalanche effect experiment
Jun 17, 2018
abdcf49
Update output's experiment
Jun 17, 2018
44bdcc7
Histogram experiment remove
Jun 17, 2018
6cd857d
Add experiment results
Jun 17, 2018
f9b1cf3
Experimentresult index
Jun 17, 2018
f9f5442
Update index numbering and linking
hafizhme Jun 17, 2018
ce081ce
Remove histogram
Jun 23, 2018
03bd3d8
Remove old experiment
Jul 1, 2018
f4ee092
Add new experiment
Jul 1, 2018
ac20656
Merge branch 'master' into experiment
Jul 10, 2018
4812473
Update experiment
Aug 4, 2018
f453c8a
Create make file
Aug 4, 2018
51a1b1b
Update make file
Aug 4, 2018
aea7328
Typo in calculate_entropy
Aug 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@
*.exe
*.out
*.app

# Others
experiment/dum/*
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
experiment-build-a:
g++ -o bin/exp-a.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/a.cpp `libpng-config --ldflags`
experiment-build-b:
g++ -o bin/exp-b.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/b.cpp `libpng-config --ldflags`
experiment-build-c:
g++ -o bin/exp-c.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/c.cpp `libpng-config --ldflags`
experiment-build-d:
g++ -o bin/exp-d.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/d.cpp `libpng-config --ldflags`
experiment-build-e:
g++ -o bin/exp-e.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/e.cpp `libpng-config --ldflags`
experiment-build-f:
g++ -o bin/exp-f.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/f.cpp `libpng-config --ldflags`
experiment-build-all:
g++ -o bin/exp-a.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/a.cpp `libpng-config --ldflags`
g++ -o bin/exp-b.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/b.cpp `libpng-config --ldflags`
g++ -o bin/exp-c.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/c.cpp `libpng-config --ldflags`
g++ -o bin/exp-d.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/d.cpp `libpng-config --ldflags`
g++ -o bin/exp-e.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/e.cpp `libpng-config --ldflags`
g++ -o bin/exp-f.o -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/f.cpp `libpng-config --ldflags`
experiment-run-all:
./bin/exp-a.o
./bin/exp-b.o
./bin/exp-c.o
./bin/exp-d.o
./bin/exp-e.o
./bin/exp-f.o
experiment-run-a:
./bin/exp-a.o
experiment-run-b:
./bin/exp-b.o
experiment-run-c:
./bin/exp-c.o
experiment-run-d:
./bin/exp-d.o
experiment-run-e:
./bin/exp-e.o
experiment-run-f:
./bin/exp-f.o
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

## System Block Diagram
![System Block Diagram](data/system-block-diagram.png)

## Deprecated System Block Diagram [[1]](https://www.researchgate.net/publication/320087595_File_To_Image_Encryption_FTIE_Menggunakan_Algoritma_Randomized_Text_Dan_Arnold_Cat_Map_ACM_Untuk_Keamanan_Transmisi_Data_Digital)
![Deprecated System Block Diagram](data/system-block-diagram-deprecated.png)
Binary file added data/system-block-diagram-deprecated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 131 additions & 0 deletions experiment/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
// g++ -o bin/exp-a -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/a.cpp `libpng-config --ldflags` && ./bin/exp-a
#include "../ftie/ftie.h"
#include "../experiment/tools.h"

#include <chrono>
#include <cstdint>
#include <fstream>
#include <random>
#include <sstream>
#include <vector>
#include <iostream>

#include "png++/png.hpp"


std::vector<uint16_t> P = {3, 1439, 3187, 5011, 6967, 9067, 11083, 13187, 15391, 17491, 19927, 22063, 24391, 26863, 29027, 31379, 33647, 35963, 38447, 40759, 43019, 45659, 48131, 50387, 52967, 55619, 57947, 60607, 62971, 65479};
std::vector<uint16_t> Q = {7, 1447, 3191, 5023, 6971, 9091, 11087, 13219, 15427, 17519, 19963, 22067, 24407, 26879, 29059, 31387, 33679, 35983, 38459, 40763, 43051, 45667, 48163, 50411, 52999, 55631, 57991, 60611, 62983, 65519};
std::vector<uint32_t> S = {20, 1102012, 8269800, 14654568, 8514112, 72359465, 8297696, 24662060, 111450600, 70082287, 235198879, 465814318, 180650199, 505938172, 200851637, 972337598, 426365137, 1242795649, 666777313, 704963584, 823914892, 993565933, 532403049, 2504300086, 1055897756, 1426192730, 3257141641, 359282555, 2439740097, 1549795366};

int main(int argc, char const *argv[]) {
try {
const char * slug = "acm_equal_n";
std::stringstream ss;

ss << "experiment/dum/" << slug << "_plainfile_1";
const std::string plainfile1FilepathStr = ss.str();
const char * plainfile1Filepath = plainfile1FilepathStr.c_str();
ss.str("");

ss << "experiment/dum/" << slug << "_plainfile_2";
const std::string plainfile2FilepathStr = ss.str();
const char * plainfile2Filepath = plainfile2FilepathStr.c_str();
ss.str("");

ss << "experiment/dum/" << slug << "_cipherimage_1";
const std::string cipherimage1FilepathStr = ss.str();
const char * cipherimage1Filepath = cipherimage1FilepathStr.c_str();
ss.str("");

ss << "experiment/dum/" << slug << "_cipherimage_2";
const std::string cipherimage2FilepathStr = ss.str();
const char * cipherimage2Filepath = cipherimage2FilepathStr.c_str();
ss.str("");

std::random_device generateRandom;

// plainfile
std::vector<uint8_t> bytes(3210000);
for (int i = 0; i < bytes.size(); i++)
bytes[i] = generateRandom();
bytes[0] = 1;
std::ofstream outfile1(plainfile1Filepath, std::ios::out | std::ios::binary);
outfile1.write((const char*)&bytes[0], bytes.size());
outfile1.close();

bytes[0] = 3;
std::ofstream outfile2(plainfile2Filepath, std::ios::out | std::ios::binary);
outfile2.write((const char*)&bytes[0], bytes.size());
outfile2.close();

// keystream
std::vector<uint8_t> keystream(10000000);
for (int i = 0; i < keystream.size(); i++)
keystream[i] = generateRandom();

// bbs
uint8_t bbs = generateRandom() % 30;
uint16_t p = P[bbs];
uint16_t q = Q[bbs];
uint32_t s = S[bbs];

// acm
uint16_t a = generateRandom();
uint16_t b = a;

uint16_t inc = 10;
uint16_t max = 300;
uint16_t init = 10;
for (uint16_t n = init; n <= max; n += inc) {

double npcr_1;
double npcr_2;
double hm_1;
double hm_2;
double ava_1;
double ava_2;
std::chrono::duration<double> enc_1;
std::chrono::duration<double> dec_1;
std::chrono::duration<double> enc_2;
std::chrono::duration<double> dec_2;

{
enc_1 = tools::chrono_deprecated_encrypt(keystream, a, b, n, plainfile1Filepath, cipherimage1Filepath);
dec_1 = tools::chrono_deprecated_decrypt(keystream, a, b, n, cipherimage1Filepath, plainfile1Filepath);

ftie::deprecated::encrypt(keystream, a, b, n, plainfile1Filepath, cipherimage2Filepath);
npcr_1 = tools::calculate_npcr(cipherimage1Filepath, cipherimage2Filepath);
hm_1 = tools::calculate_entropy(cipherimage1Filepath);

ftie::deprecated::encrypt(keystream, a, b, n, plainfile2Filepath, cipherimage2Filepath);
ava_1 = tools::calculate_avalanche(cipherimage1Filepath, cipherimage2Filepath);
} {
enc_2 = tools::chrono_encrypt(p, q, s, a, b, n, plainfile1Filepath, cipherimage1Filepath);
dec_2 = tools::chrono_decrypt(p, q, s, a, b, n, cipherimage1Filepath, plainfile1Filepath);

ftie::encrypt(p, q, s, a, b, n, plainfile1Filepath, cipherimage2Filepath);
npcr_2 = tools::calculate_npcr(cipherimage1Filepath, cipherimage2Filepath);
hm_2 = tools::calculate_entropy(cipherimage1Filepath);

ftie::encrypt(p, q, s, a, b, n, plainfile2Filepath, cipherimage2Filepath);
ava_2 = tools::calculate_avalanche(cipherimage1Filepath, cipherimage2Filepath);
}
std::cout << n << ", ";

std::cout << npcr_1 << ", ";
std::cout << hm_1 << ", ";
std::cout << ava_1 << ", ";
std::cout << enc_1.count() << ", ";
std::cout << dec_1.count() << ", ";

std::cout << npcr_2 << ", ";
std::cout << hm_2 << ", ";
std::cout << ava_2 << ", ";
std::cout << enc_2.count() << ", ";
std::cout << dec_2.count() << "\n";
}
} catch (const char * msg) {
std::cout << msg << '\n';
}
return 0;
}
134 changes: 134 additions & 0 deletions experiment/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// g++ -o bin/exp-b -std=c++17 ftie/*.h ftie/*.cpp experiment/tools.h experiment/tools.cpp experiment/b.cpp `libpng-config --ldflags` && ./bin/exp-b
#include "../ftie/ftie.h"
#include "../experiment/tools.h"

#include <chrono>
#include <cstdint>
#include <fstream>
#include <random>
#include <sstream>
#include <vector>
#include <iostream>

#include "png++/png.hpp"


std::vector<uint16_t> P = {3, 1439, 3187, 5011, 6967, 9067, 11083, 13187, 15391, 17491, 19927, 22063, 24391, 26863, 29027, 31379, 33647, 35963, 38447, 40759, 43019, 45659, 48131, 50387, 52967, 55619, 57947, 60607, 62971, 65479};
std::vector<uint16_t> Q = {7, 1447, 3191, 5023, 6971, 9091, 11087, 13219, 15427, 17519, 19963, 22067, 24407, 26879, 29059, 31387, 33679, 35983, 38459, 40763, 43051, 45667, 48163, 50411, 52999, 55631, 57991, 60611, 62983, 65519};
std::vector<uint32_t> S = {20, 1102012, 8269800, 14654568, 8514112, 72359465, 8297696, 24662060, 111450600, 70082287, 235198879, 465814318, 180650199, 505938172, 200851637, 972337598, 426365137, 1242795649, 666777313, 704963584, 823914892, 993565933, 532403049, 2504300086, 1055897756, 1426192730, 3257141641, 359282555, 2439740097, 1549795366};

int main(int argc, char const *argv[]) {
try {
const char * slug = "acm_any_n";
std::stringstream ss;

ss << "experiment/dum/" << slug << "_plainfile_1";
const std::string plainfile1FilepathStr = ss.str();
const char * plainfile1Filepath = plainfile1FilepathStr.c_str();
ss.str("");

ss << "experiment/dum/" << slug << "_plainfile_2";
const std::string plainfile2FilepathStr = ss.str();
const char * plainfile2Filepath = plainfile2FilepathStr.c_str();
ss.str("");

ss << "experiment/dum/" << slug << "_cipherimage_1";
const std::string cipherimage1FilepathStr = ss.str();
const char * cipherimage1Filepath = cipherimage1FilepathStr.c_str();
ss.str("");

ss << "experiment/dum/" << slug << "_cipherimage_2";
const std::string cipherimage2FilepathStr = ss.str();
const char * cipherimage2Filepath = cipherimage2FilepathStr.c_str();
ss.str("");

std::random_device generateRandom;

// plainfile
std::vector<uint8_t> bytes(3210000);
for (int i = 0; i < bytes.size(); i++)
bytes[i] = generateRandom();
bytes[0] = 1;
std::ofstream outfile1(plainfile1Filepath, std::ios::out | std::ios::binary);
outfile1.write((const char*)&bytes[0], bytes.size());
outfile1.close();

bytes[0] = 3;
std::ofstream outfile2(plainfile2Filepath, std::ios::out | std::ios::binary);
outfile2.write((const char*)&bytes[0], bytes.size());
outfile2.close();

// keystream
std::vector<uint8_t> keystream(10000000);
for (int i = 0; i < keystream.size(); i++)
keystream[i] = generateRandom();

// bbs
uint8_t bbs = generateRandom() % 30;
uint16_t p = P[bbs];
uint16_t q = Q[bbs];
uint32_t s = S[bbs];

// acm
uint16_t a = generateRandom();
uint16_t b = generateRandom();
while (b == a) {
b = generateRandom();
}

uint16_t inc = 10;
uint16_t max = 300;
uint16_t init = 10;
for (uint16_t n = init; n <= max; n += inc) {

double npcr_1;
double npcr_2;
double hm_1;
double hm_2;
double ava_1;
double ava_2;
std::chrono::duration<double> enc_1;
std::chrono::duration<double> dec_1;
std::chrono::duration<double> enc_2;
std::chrono::duration<double> dec_2;

{
enc_1 = tools::chrono_deprecated_encrypt(keystream, a, b, n, plainfile1Filepath, cipherimage1Filepath);
dec_1 = tools::chrono_deprecated_decrypt(keystream, a, b, n, cipherimage1Filepath, plainfile1Filepath);

ftie::deprecated::encrypt(keystream, a, b, n, plainfile1Filepath, cipherimage2Filepath);
npcr_1 = tools::calculate_npcr(cipherimage1Filepath, cipherimage2Filepath);
hm_1 = tools::calculate_entropy(cipherimage1Filepath);

ftie::deprecated::encrypt(keystream, a, b, n, plainfile2Filepath, cipherimage2Filepath);
ava_1 = tools::calculate_avalanche(cipherimage1Filepath, cipherimage2Filepath);
} {
enc_2 = tools::chrono_encrypt(p, q, s, a, b, n, plainfile1Filepath, cipherimage1Filepath);
dec_2 = tools::chrono_decrypt(p, q, s, a, b, n, cipherimage1Filepath, plainfile1Filepath);

ftie::encrypt(p, q, s, a, b, n, plainfile1Filepath, cipherimage2Filepath);
npcr_2 = tools::calculate_npcr(cipherimage1Filepath, cipherimage2Filepath);
hm_2 = tools::calculate_entropy(cipherimage1Filepath);

ftie::encrypt(p, q, s, a, b, n, plainfile2Filepath, cipherimage2Filepath);
ava_2 = tools::calculate_avalanche(cipherimage1Filepath, cipherimage2Filepath);
}
std::cout << n << ", ";

std::cout << npcr_1 << ", ";
std::cout << hm_1 << ", ";
std::cout << ava_1 << ", ";
std::cout << enc_1.count() << ", ";
std::cout << dec_1.count() << ", ";

std::cout << npcr_2 << ", ";
std::cout << hm_2 << ", ";
std::cout << ava_2 << ", ";
std::cout << enc_2.count() << ", ";
std::cout << dec_2.count() << "\n";
}
} catch (const char * msg) {
std::cout << msg << '\n';
}
return 0;
}
Loading