diff options
Diffstat (limited to '3544/CH3/EX3.3')
-rw-r--r-- | 3544/CH3/EX3.3/Ex3_3.sce | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/3544/CH3/EX3.3/Ex3_3.sce b/3544/CH3/EX3.3/Ex3_3.sce new file mode 100644 index 000000000..b80dd8d52 --- /dev/null +++ b/3544/CH3/EX3.3/Ex3_3.sce @@ -0,0 +1,41 @@ +
+//Stream cipher
+
+disp("In text format:")
+disp("Plain text")
+disp("Pay 100")
+disp("")
+
+disp("Cipher text")
+disp("ZTU91 ^%D")
+disp("")
+
+disp("")
+
+disp("In binary format:")
+
+disp("Plain text")
+
+pt = "010111001"
+
+disp(pt)
+disp("")
+
+//convert to decimal
+pt = bin2dec("010111001")
+
+disp("XOR operation with the key")
+key="100101011"
+disp(key)
+
+//convert key to decimal
+key=bin2dec(key)
+disp("")
+
+//calculate cipher text
+ct = bitxor(pt,key)
+ct = dec2bin(ct)
+
+disp("Cipher text")
+disp(ct)
+disp("")
|