summaryrefslogtreecommitdiff
path: root/3544/CH4/EX4.18/Ex4_18.sce
blob: 378f06094a6e7de5e05526b61d0ada6716b79226 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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)