diff options
Diffstat (limited to '3544/CH2/EX2.44/Ex2_44.sce')
-rw-r--r-- | 3544/CH2/EX2.44/Ex2_44.sce | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/3544/CH2/EX2.44/Ex2_44.sce b/3544/CH2/EX2.44/Ex2_44.sce new file mode 100644 index 000000000..c27d0ae1a --- /dev/null +++ b/3544/CH2/EX2.44/Ex2_44.sce @@ -0,0 +1,45 @@ +
+//Decryption
+
+// Move scilab to current file directory
+[u,t,n] = file()
+n = strcat(n)
+file_name = basename(n)+fileext(n)
+file_name = strcat(file_name)
+ind=strindex(n,file_name)
+path = part(n,1:ind-1)
+chdir(path)
+
+exec("Chapter_2.sci",-1)
+
+pt = "Ifmmp Kpio"
+
+disp("Plain-text message:")
+disp(pt)
+
+a = ascii('a')
+z = ascii('z')
+A = ascii('A')
+Z = ascii('Z')
+
+
+ct = []
+for i=1:length(pt)
+ x = ascii(part(pt(1,1),i:i))
+ if x>=A & x<=Z then
+ //function from dependency file
+ ct(1,i) = decrypt_caesar_general(part(pt,i:i),1)
+ elseif x>=a & x<=z then
+ c = convstr(part(pt,i:i),'u')
+ c = decrypt_caesar_general(c,1)
+ c = convstr(c,'l')
+ ct(1,i) = c
+ else
+ ct(1,i) = part(pt,i:i)
+ end
+end
+
+ct = strcat(ct)
+disp("")
+disp("Cipher text")
+disp(ct)
|