Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################ encoding #################
- msg='Enter the message to encode it :';
- plainText=input( msg , 's')
- for i =1 : length(plainText)
- if ( plainText(i)>="a" && plainText(i)<="z")
- continue ;
- elseif (plainText(i) !=" " )
- disp('can not be encode this message ')
- return ;
- end
- end
- k= input('Enter the value of K :')
- for i =1 : length(plainText)
- if (plainText(i) !=" " )
- plainText(i)= mod(plainText(i)-'a' + k , 26) +'A';
- end
- end
- disp('the encoded message : ');
- disp( plainText);
- ################ decoding #################
- msg='Enter the message to decode it :';
- plainText=input( msg , 's')
- for i =1 : length(plainText)
- if ( plainText(i)>="A" && plainText(i)<="Z")
- continue ;
- elseif (plainText(i) !=" " )
- disp('can not be decode this message ')
- return ;
- end
- end
- k= input('Enter the value of K :')
- for i =1 : length(plainText)
- if (plainText(i) !=" " )
- plainText(i)= mod(plainText(i)-'A' - k , 26) +'a';
- end
- end
- disp('the decoded message : ');
- disp(plainText);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement