I just came up with this idea that I can store passwords as integers which take up 4 or 8 bytes as opposed to a hash that takes like 150 bytes or something. I wrote this function that converts a string to an integer based on some elementary math
function pass($pass) {
$value = 0;
for ($i = 0, $l = strlen($pass); $i < $l; $i++) {
$value += pow(ord(~$pass[$i]), 1/2);
}
return (int)round(pow($value, (int)('1.' . $value)) * 10000000000);
}
var_dump(pass('M'));
var_dump(pass('m'));
int(133416640641)
int(120830459736)
As I see it in order to get hacked first the hacker needs to know the int value stored for the password and the algorithm. They can get the value either if they hack my database or grab an old backup file which is known to be the more common exploit (I guess) but still if they don't know the algorithm they wouldn't be able to crack it?
I don't think it is possible to revert a converted value back to the original string as that would be a problem with complexity of however many characters the string contains, right?
The other possibility is if they accidentally input a value that converts to the same value of the original password, theoretically I suppose there should be an infinite amount of strings that can get converted to the same value but I'm not sure about the real chances of this happening, as well as this problem is also present in hashing algorithms known as collision.
As you probably guessed already I'm very far from a security expert and I suppose this is all garbage that I'm talking right now but I want to know why?