From 841b60a2ac7d03feb7cd60aabd60998d91ff896f Mon Sep 17 00:00:00 2001 From: Vipin Thomas <vipin.thomas@stud.th-deg.de> Date: Sat, 5 Jun 2021 21:08:45 +0000 Subject: [PATCH] Update pixel.cpp --- pixel.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/pixel.cpp b/pixel.cpp index ecb2850..4f6c1a7 100644 --- a/pixel.cpp +++ b/pixel.cpp @@ -7,11 +7,16 @@ using namespace std; typedef ap_axis<32,0,0,0> pkt_t; static int count_streams = 0; static long long charIn=0; +static int addNum=0; +static int decrpyt=0; +static long long asciiNum=0; +static int asciiVal=0; -long long convert(int n) +long long convert(int n); long long toAscii(chr number); int convertBinInt(long long n); - +char stegnoDcrypt(int data); +void stegno(char c); void pixel( ap_int<32> position1, @@ -28,21 +33,26 @@ void pixel( #pragma HLS INTERFACE s_axilite port=w #pragma HLS INTERFACE s_axilite port=h #pragma HLS INTERFACE s_axilite port=character + #pragma HLS INTERFACE s_axilite port=selector //switch for encrypt and decrypt #pragma HLS INTERFACE axis port=din #pragma HLS INTERFACE axis port=dout + pkt_t pkt=din.read(); - charIn=toAscii(character) + switch(selector) + { + case 0: + stegno(character); + break; - pkt_t pkt=din.read(); + case 1: + stegnoDecrypt(); + break; + + default: + break; + } - if(count_streams > 3 * (position - 1) && count_streams < 3 * (position2)){ - addNum=charIn%10; - charIn=(int)charIn/10; - pkt.data=convertBinInt((convert(pkt.data)/10)*10+addNum); - - } - count_streams++; if (count_streams == w*h*3){ @@ -57,6 +67,36 @@ void pixel( } +void stegno(char c){ + + + charIn=toAscii(character); + if(count_streams > 3 * (position - 1) && count_streams < 3 * (position2)){ + addNum=charIn%10; + charIn=(int)charIn/10; + pkt.data=convertBinInt((convert(pkt.data)/10)*10+addNum); + + } + +} + +char stegnoDcrypt(int data){ + + + //int arr[8]={255,254,253,252,251,250,249,248}; + + decrpyt=convert(data)%10; + printf("%d\n",decrpyt); + + asciiNum=asciiNum*10+decrpyt; + + asciiVal= convertBinInt(asciiNum); + printf("%d\n",asciiVal); + return (char)asciiVal; + +} + + long long convert(int n) { long long bin = 0; int rem, i = 1, step = 1; -- GitLab