0

I have these methods of encryption to C #, I need this even for PHP, could someone help me convert?

C#

private string GeraSenha(string userPassword)
            {
               string pwdToHash = userPassword + "^Y8~JJ";

               string hash = BCryptHelper.HashPassword(pwdToHash, BCryptHelper.GenerateSalt());
               return hash;
             }

            private bool ChecaSenha(string hashedPwdFromDatabase, string userEnteredPassword)
            {
                return BCryptHelper.CheckPassword(userEnteredPassword + "^Y8~JJ", hashedPwdFromDatabase);
            }

PHP

function CriptSenha($senha) {
    $pwdToHash = $senha . "^Y8~JJ"; // ^Y8~JJ is my hard-coded salt
    $hash = Bcrypt::hash($senha);
    //$hash = BCryptHelper.HashPassword($pwdToHash, BCryptHelper.GenerateSalt());

    return $hash;
}

function UncriptSenha($senhadb, $senha) {
    if (Bcrypt::check($senha . "^Y8~JJ", $senhadb)) {
        return true;
    } else {
        return false;
    }
}

in php the method to check is picking up, but not to encrypt. I need you to help me fix this

  • Take a look here: http://stackoverflow.com/questions/4795385/how-do-you-use-bcrypt-for-hashing-passwords-in-php – GluePear May 18 '14 at 21:04
  • It's good that you took the advice on [your previous question](http://stackoverflow.com/questions/23716537/c-hash-sha256), but please-help-me-convert-this questions are a bit broad for here. Could you give it a try, and let us know where you get stuck? – halfer May 18 '14 at 21:18
  • Php Added in first post – LucasGuitar May 19 '14 at 02:59

0 Answers0