I have recently created a code for hashing password. Can you please give your advice over the security of my code? The function takes a password, then converts it to a number.
#include <string>
#include <cmath>
int mod(int x, int y) {
return x - floor((double) x/y) * y;
}
int crypt(string str) {
int z = 0;
for(int i = 0; i < str.size(); i++)
z += mod( ( str[i] * -(str[i]) ), ((i*29) + 2999) );
return z;
}
int password = crypt("Password1");
bool auth(string pass, int x) {
if (crypt(pass) == x) return true;
else return false;
}