%spoke test assuming alphabet using starts with ascii character inputed as
%starlet
function hashing = ultspoke2(messy,keyy,L,starlet,outl) %input message in string format, key in string format, length of alphabet(#), and decimal value (ascii) of starting character of the alphabet 
mes=double(messy)-starlet;%decimal rep of each letter in message(first letter in alphabet=0)
k=double(keyy)-starlet;% decimal rep of key
h=(log(L-1))/(log(2));
s=floor(h)+1;%number of bits per letter
if s==1;
    s=2;
end;
n=length(mes); %n=number of letters in message
N=s*n; %N=number of bits in message, for s bit rep of letters
keys = 0:L-1;
keybin=dec2bin(keys,s);%to initialize set of all possible key letters in binary form
message=dec2bin(0,N);%to initialize message
key=zeros(1,s);%to initialize key vector
hash=zeros(s,n+1);%to initialize matrix to be xored
hashlet=zeros(1,s);%to initialize vector represented final hash output
for p=1:n; %to determine what binary number each letter in the message is
   for e=1:L;
      for g=1:s;
          if ((mes(p)<e) && (mes(p)>e-2)); 
              message((s*p)-(s-g))=num2str(keybin(e,g));
          end;
      end;
   end;
end;
for q=1:L; %to determine binary representation of key
    for t=1:s;
        if ((k<q) && (k>q-2)); 
            key(t)=str2num(keybin(q,t));
        end;
    end;
end;
for f=1:s;
    hash(f,1)=key(f);% to choose each part of binary representation of key
end;
for w=1:s; %for each spoke
    for i=1:n; %for each letter
        if (rem(w+2,2)>0);%for every odd numbered channel (spoke)
            hash(w,i+1)=xor(str2num((message((w*n)-n+i))),hash(w,i));% to apply xor to corresponding odd numbered spokes
        else %for every even numbered channel (spoke)
            hash(w,i+1)=xor(str2num((message((w*n)+1-i))),hash(w,i));%to apply xor to corresponding even numbered spokes (reverse order)
        end;
    end;
end;
for o=1:outl;%for all of the desired character outputs
    for h=1:s;%for each bit of a character
        hashlet(o,h)=(hash(h,n+2-o))';%organize binary hash outputs in a matrix, with each character (in binary form) on a seperate row
    end;
end;
hashing=bin2dec(num2str(hashlet))+starlet;%convert each binary rep of each hash character into its correspondng ascii decimal value
