私はthis blog postとこれをstack overflow postと読んでいますが、ハッシュフォームフィールド(ハニーポットの部分はウェブ上に多くの例があるようです)の経験はあまりありません。質問。PHPハッシュ入力フィールド名
質問1
が、それはこのようなものですか、私は道オフベースのですか?フォーム上(注、これは簡潔にするためだけのタイムスタンプを持つ簡単な例である)
PHP:
<form action="register.php" method="post">
<input type="text" name="<?php echo $first_name ?>" >
<input type="hidden" name="check" value="<?php echo $time ?>" >
<input type="submit" name="register">
</form>
Register.php
// check to see if there is a timestamp
if (isset($_POST['check'])) {
$time = strtotime($_POST['check']);
if (time() < $time) {
// original timestamp is in the future, this is wrong
}
if (time() - $time < 60) {
// form was filled out too fast, less than 1 minute?
}
// otherwise
$key = $_POST['check'];
if (md5($key + 'first_name') == $_POST['whatever-the-hash-on-the-first_name-field-was']) {
// process first_name field?
}
}
:
$time = mktime();
$first_name = md5($time + 'first_name');
HTMLフォームに
質問2:
どのようにフィールド名のハッシュは、物事をより安全にするのでしょうか?私はタイムスタンプのチェックを得る(私はブログの投稿の部分を "過去にあまりにも遠すぎる"とは理解していないが...ボットがそれをあまりにも速く記入しないだろうか?)しかし、私はハッシュname属性は正確に行います。フィールドの名前をランダム化します
<form action="register.php" method="post">
<? $timestamp = time() ?>
<!-- This is where the user would put the email. Don't put this comment in for real -->
<input type="text" name="<?php echo md5("email" . $timestamp . $secretKey) ?>" >
<input type="hidden" name="check" value="<?php echo $timestamp ?>" >
<input type="submit" name="register">
</form>
:あなたはそれをクライアントに送信する前にフィールド名サーバ側をハッシュする必要が
ハッシュは彼らが – SupremeDud
デコードは言葉の悪い選択で復号することができない、一つの方法です。私は、フォームが作成したハッシュと、「チェック」フィールドに基づいて結果とされた名前とを比較することを意味していました。 – redconservatory
また、この例でmd5を使用しているか、SHA2を使用していなくてもかまいませんか? – redconservatory