function hashing = netpad(mes,L,starlet,ringlength,numofhash,layernum)%L is number of different characters in alphabet,starlet is starting character of alphabet in decimal rep(ascii), ringlength is number of bits in each ring, numofhash is the number of desired hash numbers, layernum is min fix amount of layers
mes=double(mes)-starlet;%decimal rep of each letter in message (first letter in alphabet=0)
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
lets=dec2bin(0:L-1,s);%to initialize set of all possibl letters in binary form
message=dec2bin(0,N);%to initialize message
hash=zeros(s,n+1);%to initialize matrix to be xored
hashlet=zeros(1,s);%to initialize vector represented final hash output
hashout=numofhash*s;%number of bits of output hash
if rem(ringlength,hashout*log(2))>0;%if ringlength is not of correct size for model
    ringlength=(2^(floor(log(floor(ringlength/(hashout)))/log(2))+1))*hashout;
else
    ringlength=ringlength;
end;
unpadmes=(floor((N-1)/ringlength)+1);%number of layers needed to fit all bits of message
if unpadmes<=layernum;%if minimum layer amount is equal to or less than number of layers needed to fit all bits of message
    level=layernum;%actual amount of layers in petri-dish is minimum amount of layers
else%if minimum layer amount>number of layers needed to fit all bits of message
    level=unpadmes;%actual amount of layers in petri-dish =number of layers needed to fit all bits of message
end;
endmes=N-((unpadmes-1)*ringlength);%number of bits of message on last layer of layers needed to fit all bits of message
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(lets(e,g));
          end;
      end;
   end;
end;
cells=level*ringlength;%number of total cells on in petri-dish (counting all cells in each ring on each level)
trep = floor(cells/N)+1; %number cycles of message total to fill all cells
messagep=message;
if N<cells;%if message needs any padding
    for i=1:trep-1;% for number of times message needs to be repeated
        messagep=[messagep,message];
    end;
end;
times=(log(ringlength/hashout))/(log(2));%number of times to xor from outside ring to inside ring
for g=1:level*ringlength; %to initiliaze first set of numbers to be xored
    hash(1,g)=str2num(messagep(g));
end;
if times>0; %if the circumference isn't equal to bits of hash output, xor inward until have amount of bits of hash output
   for j=2:times+1;%for each time the message must be xored inward
       for i=1:((ringlength*level)/(2^(j-1))); %for every other bit on the ring being xored 
           hash(j,i)=xor(hash((j-1),((2*i)-1)),hash((j-1),(2*i)));%xor that bit with the bit next to it
        end;
    end;
end;
hash=hash(times+1,:);%make matrix of bits of each layers hash values (each layer is a row)
for i=1:hashout;%for each bit of final hash output
    for j=1:level-1;%for each level (not counting first level)
        hash(i)=xor(hash(i),(hashout*j)+1);%xor each hash value with xored hash value on the layer above (just hash value on first level)
    end;
end;
for o=1:numofhash;%for all of the desired character outputs
    for h=1:s;%for each bit of a character
        hashlet(o,h)=(hash(s*(o-1)+h))';%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