% function to read in a file and apply a random permuation
function   rp_code(filename)
  
   % read in file to be encrypted/decrypted 
   fileID=fopen(filename);
   input_text=fread(fileID)';
   fclose(fileID);
   % throw away all entries  excepts letters and spaces
   % convert all letters to uppercase
   counter=0;
   for k=1:length(input_text)
       letter=input_text(k);
       if letter ==32
           counter=counter+1;
           plain_text(counter)=letter;
       elseif (65<=letter)&&(letter<=90)
           counter=counter+1;
           plain_text(counter)=letter;
       elseif (97<=letter)&&(letter<=122)
           counter=counter+1;
           plain_text(counter)=letter-32;
       end        
   end 
   % show the modified text
   char(plain_text)
   % create new_text with shifted letters
   perm=randperm(26);
   new_text = plain_text;
   for k=1:length(new_text)
       letter=new_text(k);
       if   (65 <= letter)&&(letter <= 90)
           new_text(k) = 64+perm(letter-64);
       end % end if
   end % for k
   % save encrypted text to a file
   % use same name, but add '.caesar' to end
   out=char(new_text)
   out_filename=[filename,'.rp'];
   fileID=fopen(out_filename,'w+');
   fwrite(fileID,out);
   fclose(fileID);
return
