Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
hash_password function on C#
  • 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
    And then Converting the hash result using ToBase64String. But no luck so far.

    Thanks in advance for any help.
  • 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;
  • HarroHarro
    Accepted Answer
    This is the PHP code that is used:

    Perhaps that gives some pointers?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion