hash - Custom C++ ASP .NET Membership Login -
hash - Custom C++ ASP .NET Membership Login -
does know how can hash user's password using salt key provided asp .net membership?
i'm developing c++ linux application , have access sql server.
thanks,
here encoding algorithm used asp.net membership written in c#.
it uses system.security, might want @ mono if want run on lunix.
note: i'm not familiar mono.
private string encodepassword(string pass, int passwordformat, string salt) {     if (passwordformat == 0) // membershippasswordformat.clear          homecoming pass;      byte[] bin = encoding.unicode.getbytes(pass);     byte[] bsalt = convert.frombase64string(salt);     byte[] bret = null;      if (passwordformat == 1)     { // membershippasswordformat.hashed         hashalgorithm hm = gethashalgorithm();         if (hm keyedhashalgorithm)         {             keyedhashalgorithm kha = (keyedhashalgorithm)hm;             if (kha.key.length == bsalt.length)             {                 kha.key = bsalt;             }             else if (kha.key.length < bsalt.length)             {                 byte[] bkey = new byte[kha.key.length];                 buffer.blockcopy(bsalt, 0, bkey, 0, bkey.length);                 kha.key = bkey;             }             else             {                 byte[] bkey = new byte[kha.key.length];                 (int iter = 0; iter < bkey.length; )                 {                     int len = math.min(bsalt.length, bkey.length - iter);                     buffer.blockcopy(bsalt, 0, bkey, iter, len);                     iter += len;                 }                 kha.key = bkey;             }             bret = kha.computehash(bin);         }         else         {             byte[] ball = new byte[bsalt.length + bin.length];             buffer.blockcopy(bsalt, 0, ball, 0, bsalt.length);             buffer.blockcopy(bin, 0, ball, bsalt.length, bin.length);             bret = hm.computehash(ball);         }     }     else     {         byte[] ball = new byte[bsalt.length + bin.length];         buffer.blockcopy(bsalt, 0, ball, 0, bsalt.length);         buffer.blockcopy(bin, 0, ball, bsalt.length, bin.length);         bret = encryptpassword(ball, _legacypasswordcompatibilitymode);     }       homecoming convert.tobase64string(bret); }  private string generatesalt() {     byte[] buf = new byte[salt_size];     (new rngcryptoserviceprovider()).getbytes(buf);      homecoming convert.tobase64string(buf); }        c++ hash asp.net-membership 
 
Comments
Post a Comment