[HELP]whirlpool
#1

hello as my first topic was about the same problem in a different way I did something new in da dudb include and hashing, but I got some errors I hope this thing can work
my code:

pawn Код:
stock udb_CheckLogin(nickname[],pwd[]) {
  new fname[MAX_STRING], hashpass[129];
  WP_Hash(hashpass,sizeof(hashpass),pwd);
  format(fname,sizeof(fname),"SFTDM/Users/%s.sav",udb_encode(nickname));
  if (udb_UserInt(nickname,"password_hash")==hashpass) return true;
  return false;
}


stock udb_Create(nickname[],pwd[]) {
  if (udb_Exists(nickname)) return false;
  new fname[MAX_STRING], hashpass[129];
  WP_Hash(hashpass,sizeof(hashpass),pwd);
  format(fname,sizeof(fname),"SFTDM/Users/%s.sav",udb_encode(nickname));
  dini_Create(fname);
  udb_UserSetInt(nickname,"password_hash",hashpass);
  return true;
}
ma errors

PHP код:
blabla\include\dudb.inc(141) : error 033: array must be indexed (variable "hashpass")
blabla\include\dudb.inc(152) : error 035argument type mismatch (argument 3
Reply
#2

Can you show us the lines which makes the error ? (Basically, the 141 and the 152)

We can't guess your code, just a possible cause of the problem.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
The problem is most likely that "udb_hash" returns a number (which is why it is so bad - there are too few values it can take to be secure), and "WP_Hash" returns a string so is not a drop-in replacement.
I haven't really used udb much, but I'm assuming that 'dUserSetInt' is not the right function to use in the case of setting a string.

EDIT:
Код:
udb_UserSet(nickname[],key[],value[])
This may be what you're after.
Reply
#4

@Threshold : I think it's more possible that the problem comes from here

pawn Код:
if (udb_UserInt(nickname,"password_hash")==hashpass) return true;
Because he checks if a number (or at least this is what's suggested by the use of "udb_UserInt") corresponds to an array. (he should use strcmp instead).

But till' I haven't seen the error lines, I can't judge.
Reply
#5

Yes I realise that, what I'm saying is that he is trying to compare an integer with a string rather than a string with a string.

pawn Код:
stock udb_CheckLogin(nickname[], pwd[])
{
    new fname[MAX_STRING], hashpass[129];
    WP_Hash(hashpass, sizeof(hashpass), pwd);
    format(fname, sizeof(fname), "SFTDM/Users/%s.sav", udb_encode(nickname));
    if(!strcmp(udb_User(nickname, "password_hash"), hashpass, false)) return true;
    return false;
}


stock udb_Create(nickname[], pwd[])
{
    if (udb_Exists(nickname)) return false;
    new fname[MAX_STRING], hashpass[129];
    WP_Hash(hashpass, sizeof(hashpass), pwd);
    format(fname, sizeof(fname), "SFTDM/Users/%s.sav", udb_encode(nickname));
    dini_Create(fname);
    udb_UserSet(nickname, "password_hash", hashpass);
    return true;
}
Not much knowledge of udb once again, but this is my attempt.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)