Irreversible one-way function
3 views (last 30 days)
Show older comments
Hi all,
I am creating a code which will perform a one-way irreversible function for protecting passwords. I don't want to use encryption methods, as this can be easily decrypted.
I have developed this code:
myString = 'hello, World';
ASCII = double(myString);
accum = 0;
m = 256^2;
hex = cell(size(ASCII));
for i=1:length(ASCII)
accum = (ASCII(i) + accum);
primeaccum = accum * 37;
modulus = mod(primeaccum,m);
hex{1,i} = dec2hex(primeaccum);
end
where 'hello,World' is sitting in place of the where the password would be input.
Please could you help provide any feedback/suggestions as to whether you think the code would work for this function?
Thanks, J
2 Comments
John D'Errico
on 31 Mar 2015
I'm confused. It looks like you have a pretty simple scheme here, that to me does not look irreversible. As for the "simple encryption" methods you refer to, if they are as easily decrypted as you say, then why is this not? And why are there so many people working on RSI schemes and the like? Gosh, if it is so easy, then they are all just wasting their time.
Joseph Cheng
on 31 Mar 2015
Edited: Joseph Cheng
on 31 Mar 2015
well you would want to change your m to something smaller as it is doing nothing for you with that length of password. also use it in your calculation.
revhex=hex2dec(hex);
revprime=revhex/37;
revAscii(1)=revprime(1);
for i = 2:length(ASCII)
revAscii(i) = revprime(i)-sum(revAscii(1:i-1));
end
disp(char(revAscii))
the code snippit above is enough to backtrace what you've done. especially since revhex(1) is not adjusted by anything and can be used to find the other portions. with a bit of time someone could probably figure out that you've used 37 as a constant.
Answers (0)
See Also
Categories
Find more on Language Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!