diff --git a/pixel.cpp b/pixel.cpp
index ecb2850cfc784a790b1aa9dd9ac5295e7b4d2af8..4f6c1a7da1e20969e9e30c11584d43827636aeac 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;