Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- enc = 'rbuxd';
- oenc = unique(enc);%ordered enc with no duplicates
- y = double(oenc)-96; %array of the codomain, with letters as alphabetic values
- % string length of oenc = array size of y
- length = numel(oenc);
- %consider if there are only advances
- alladvances=[];
- alladvancesstr='a';
- if y(1)~=1
- for a = 1:length
- alladvances(a) = y(a)- a; %shifting back 'a' places
- end;
- end;
- for a =1:numel(alladvances)
- alladvancesstr(a)=char(alladvances(a)+96);
- end;
- clc;
- alladvancesstr
- %% number of wraps = size of codomain, n, of first letters of alphabet, which are common to codomain.
- %% eg if codomain has size = 5, then the number of possible wraps = number of letters which are in codomain
- %% and first 5 letters of alphabet
- numwraps = 0;
- for a = 1:length %working out how # of possible wraps = numwraps
- if (y(a)>= 1 & y(a)<= length)
- numwraps=numwraps+1;
- end;
- end;
- numwraps
- wraps=[];
- for a = 1:numwraps
- wraps(a)=y(a); %% this finds which letters (as alphabetic numbers though) could be wraps
- end;
- wraps
- %need to consider number of wraps from 1 to numwraps
- %start at 1, then do 2 or 3 and generalise
- % considering only 1 wrap here, so could be 1st wraps, 2nd wraps, 3rd wraps,..., numwraps wraps
- % consider 1st letter wraps - what are the limits of a wrap?
- %%then consider 2 wraps
- %%1st & 2nd, 1st & 3rd,...,1st & numwraps; then 2nd & 3rd, 2nd & 4th,...,2nd &numwraps;...;numwraps-1 and numwraps
- %%consider 3 wraps
- %% 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)
- %%need to substitute letters in enc to find the possible plaintexts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement