Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Auth
hash_password function on C#
asanchez
June 2014
Hi all,
I'm developing a mobile app. The users have to be able to sign in to the app with the same user and password that they use to log in in the website. But so far I've been unable to reproduce the hash_password() function from FuelPHP using C#
I've tried using this c# code for the pbkdf2
http://www.jmedved.com/2012/04/pbkdf2-with-sha-256-and-others/
And then Converting the hash result using ToBase64String. But no luck so far.
Thanks in advance for any help.
asanchez
June 2014
The code for the pbkdf2 is
private byte[] Func() {
var hash1Input = new byte[this.Salt.Length + 4];
Buffer.BlockCopy(this.Salt, 0, hash1Input, 0, this.Salt.Length);
Buffer.BlockCopy(GetBytesFromInt(this.BlockIndex), 0, hash1Input, this.Salt.Length, 4);
var hash1 = this.Algorithm.ComputeHash(hash1Input);
byte[] finalHash = hash1;
for (int i = 2; i <= this.IterationCount; i++) {
hash1 = this.Algorithm.ComputeHash(hash1, 0, hash1.Length);
for (int j = 0; j < this.BlockSize; j++) {
finalHash[j] = (byte)(finalHash[j] ^ hash1[j]);
}
}
if (this.BlockIndex == uint.MaxValue) { throw new InvalidOperationException("Derived key too long."); }
this.BlockIndex += 1;
return finalHash;
}
Harro
June 2014
Accepted Answer
This is the PHP code that is used:
https://github.com/fuel/core/blob/1.8/develop/vendor/phpseclib/Crypt/Hash.php#L360
Perhaps that gives some pointers?
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
asanchez
June 2014
Harro
June 2014