English 中文(简体)
检查输入的密码是否正确, 是否与 PHP 中的 sha256 pw 匹配
原标题:Check entered password if its correct, match with sha256 pw in PHP
  • 时间:2012-05-25 17:09:20
  •  标签:
  • php

我有密码;

828b8f98ec52c750bf018c92951c6e40ae3976e74c888e42ff55ff22403932af

我通常使用Kohana 3 进行Auth登录。

现在我需要做一个单独的脚本, 客户端只能输入密码, 然后它应该检查密码是否正确 。

因此,我所要处理的是:

$real_pwd =  828b8f98ec52c750bf018c92951c6e40ae3976e74c888e42ff55ff22403932af ;
$entered_pwd = $_GET[ pwd ]; // test purposes i know its vuln for sql injection ...

if ( $real_pwd == crypt($entered_pwd) ) { echo "OK"; }

这不是正常的,加密 () 是我尝试过的, 但我不知道该用什么?

如果它是 sha1 pw, 我可以用 sha1 来表示输入的\ pwd, 但是如果是 sha256呢?

最佳回答

您可以使用 hash () < a href="http://php. net/ manual/ en/ opident. hash.php" rel = "no follown noreferrer" > http://php. net/ manual/ en/ confer.hash.php

不过我还是建议你看一下bcrypt, 并用它来做草签密码。 请在这里查看 < a href="https://stackoverflow.com/ questions/4795385/ how- do- do-you- use- bcrypt- for- hashing- passwords- in-php" 您如何使用 bcrypt 来在 PHP 中使用 hash 密码?

Here s some other resources you might find useful: Secure hash and salt for PHP passwords

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签