Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. clear;
  2. enc = 'rbuxd';
  3. oenc = unique(enc);%ordered enc with no duplicates
  4. y = double(oenc)-96; %array of the codomain, with letters as alphabetic values
  5. % string length of oenc = array size of y
  6. length = numel(oenc);
  7.  
  8.  
  9. %consider if there are only advances
  10. alladvances=[];
  11. alladvancesstr='a';
  12. if y(1)~=1
  13. for a = 1:length
  14. alladvances(a) = y(a)- a; %shifting back 'a' places
  15. end;
  16. end;
  17.  
  18. for a =1:numel(alladvances)
  19. alladvancesstr(a)=char(alladvances(a)+96);
  20. end;
  21. clc;
  22. alladvancesstr
  23.  
  24.  
  25. %% number of wraps = size of codomain, n, of first letters of alphabet, which are common to codomain.
  26. %% eg if codomain has size = 5, then the number of possible wraps = number of letters which are in codomain
  27. %% and first 5 letters of alphabet
  28.  
  29. numwraps = 0;
  30. for a = 1:length %working out how # of possible wraps = numwraps
  31. if (y(a)>= 1 & y(a)<= length)
  32. numwraps=numwraps+1;
  33. end;
  34. end;
  35. numwraps
  36.  
  37. wraps=[];
  38. for a = 1:numwraps
  39. wraps(a)=y(a); %% this finds which letters (as alphabetic numbers though) could be wraps
  40. end;
  41. wraps
  42.  
  43. %need to consider number of wraps from 1 to numwraps
  44. %start at 1, then do 2 or 3 and generalise
  45.  
  46. % considering only 1 wrap here, so could be 1st wraps, 2nd wraps, 3rd wraps,..., numwraps wraps
  47. % consider 1st letter wraps - what are the limits of a wrap?
  48.  
  49.  
  50.  
  51. %%then consider 2 wraps
  52. %%1st & 2nd, 1st & 3rd,...,1st & numwraps; then 2nd & 3rd, 2nd & 4th,...,2nd &numwraps;...;numwraps-1 and numwraps
  53.  
  54. %%consider 3 wraps
  55. %% 1st 2nd 3rd, 124, 125,...,12numwraps;134,135,...,13numwraps;...;1(numwraps-1)numwraps. 234,235,...,23numwraps; 245,246,...,24numwraps;...,2(numwraps-1)numwraps......(numwraps-2)(numwraps-1)(numwraps)
  56.  
  57.  
  58.  
  59.  
  60. %%need to substitute letters in enc to find the possible plaintexts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement