Name: Anonymous 2013-10-20 22:56
Post a random function that you made. May be from any project you've done or make one impromptu.
Any QUALITY is allowed. No bullying!
Any QUALITY is allowed. No bullying!
alpha = "abcdefghijklmnopqrstuvwxyz";
rnonce = ceil(rand(1) * 10) + 5;
nonce = ceil(rand(1,rnonce) * 26);
nonce = nonce(nonce != key(3));
rnonce = length(nonce);
key = [1,2,3];
inpstr = "CAPSTEST";
outpstr = '';
lastinp = 0;
for(i=1:rnonce)
lastinp = mod(lastinp + nonce(i) - 1, 26) +1;
outpstr(i) = alpha( mod(lastinp + key(mod(i, 3)+1)-1, 26) +1 );
endfor;
lastinp = mod(lastinp + key(3) - 1, 26) +1;
outpstr(i) = alpha( mod(lastinp + key(mod(i, 3)+1)-1, 26) +1 );
for(j=1:length(inpstr))
val = 0;
for(iter = 1:length(alpha))
val = val + (inpstr(j) == alpha(iter)) * iter;
endfor;
lastinp = mod(lastinp + val - 1, 26) +1;
outpstr(j+i) = alpha( mod(lastinp + nonce(mod(i, rnonce)+1)-1, 26) +1 );
if(inpstr(j) == ' ')
outpstr(j+i) = ' ';
endif;
endfor;
outpstr