I have made this function to extract the first 2 characters of a string:
string get_salt(string hash)
{
char pre_salt[2];
for (int i = 0; i < 2; i++)
{
pre_salt[i] = hash[i];
}
string salt = pre_salt;
printf("%s\n", salt);
return(salt);
}
But when I run it with a string that has "50" (is the example I'm using) as the first 2 characters, I get this output:
50r®B
And to be honest I have no idea why is it adding the 3 extra characters to the resulting string.