에서 볼 수 있으므로 이미 디코딩하고 인코딩하는 방법을 이미 관리했습니다. 이는 2 가지 기능을 통해 수행됩니다. 그래서 여기에 결과 페이지에서와 같이 양식 데이터를 암호화되었지만 URL
http://goldextra.com/b/id_color.php
당신이 단어를 입력하면
, 그것은 인코딩 얻을 것이다 예이다. 하나의 입력 그렇다면 = testword URL이 일이 http://goldextra.com/b/balloony.php?name=testword것 대신에 나는 자체 점검이 http://goldextra.com/b/balloony.php?name=k484z52646w5i474 (물론 사이트처럼 보이게 의 URL을 원하는 암호화는 보이지 않지만 단어는 표시되지 않습니다.)
지금 가지고있는 코드를 어떻게 변경해야하나요? 폼 사이트 나 resu에서 코드를 변경해야합니까? 사이트?
FORM 코드
<form action="balloony.php" class="sign-up" method="get" class="sign-up">
<h1 class="sign-up-title">Whats the word?</h1>
<input type="text" class="sign-up-input" placeholder="Enter your baloony" name="name" autofocus>
<input type="submit" value="baloony it!" class="sign-up-button">
결과 사이트
<?php
function encode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i++) {
$ordStr = ord(substr($string,$i,1));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36));
}
return $hash;
}
function decode($string,$key) {
$key = sha1($key);
$strLen = strlen($string);
$keyLen = strlen($key);
for ($i = 0; $i < $strLen; $i+=2) {
$ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16));
if ($j == $keyLen) { $j = 0; }
$ordKey = ord(substr($key,$j,1));
$j++;
$hash .= chr($ordStr - $ordKey);
}
return $hash;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo htmlspecialchars($_GET["name"]) . '!'; ?></title>
<style type="text/css">
.BIG {
font-size: 250px;
font-weight: bold;
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
text-align: center;
}
</style>
</head>
<body class="BIG">
<?php
$name = htmlspecialchars($_GET['name']);
$urlENC = encode($name ,"whateverkey");
$urlDEC = decode($urlENC ,"whateverkey");
echo htmlspecialchars($_GET["url"]) . '';
echo $urlENC; ?>
<br />
<? echo $urlDEC; ?>
양식 제출시 값을 인코딩하려면 javascript가 필요합니다. 그러나 정확한 목적은 무엇입니까? 그것이 안전하다면, ssl을 사용하는 것이 훨씬 더 좋은 선택입니다. – jeroen
당신이 달성하고자하는 것은 거의 무의미하지만, 가장 직접적인 방법은 자바 스크립트 함수를 만드는 것입니다. – Kei
그래, URL에 양식 정보가 포함되기를 바랍니다. 사람들이 링크를 copypaste 수 있습니다. 하지만 나는 사람들이 단지 URL을보고 내용이 무엇인지 알기를 원하지 않습니다. @ 케이 어떻게 그 기능을 정확히 구현할 수 있습니까? (신인으로서 나는 아직도 ...) – TobiasH