summaryrefslogtreecommitdiff
path: root/3544/CH4/EX4.18/Ex4_18.sce
diff options
context:
space:
mode:
Diffstat (limited to '3544/CH4/EX4.18/Ex4_18.sce')
-rw-r--r--3544/CH4/EX4.18/Ex4_18.sce17
1 files changed, 17 insertions, 0 deletions
diff --git a/3544/CH4/EX4.18/Ex4_18.sce b/3544/CH4/EX4.18/Ex4_18.sce
new file mode 100644
index 000000000..378f06094
--- /dev/null
+++ b/3544/CH4/EX4.18/Ex4_18.sce
@@ -0,0 +1,17 @@
+// Simple message digest
+
+n = 7391743 //Message
+printf("Original number is %d\n",n)
+
+n_str = string(n) //Conversion of integer to string for easy access
+l = length(n_str)
+n_v = strsplit(n_str,1:l-1) //String to vector of characters
+
+d = 1
+for i=1:l
+ d = d * ( ascii(n_v(i:i)) - ascii('0')) //
+ d = modulo(d,10)
+ i = i+1
+end
+
+printf("Message digest is %d\n",d)