|
 |
|
ช่วยดู PHP ทีครับว่าผิดตรงไหน ช่วยแนะแนวทางการแก้ไขทีครับ |
|
 |
|
|
 |
 |
|
ต้องการจะทำการ Encryption แบบในรูป แต่ทำแล้วมันออกเป็น 0 ตลอดเรยครับ ผมควรแก้ไขตรงไหนบ้าง

Code (PHP)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>En - Decryption</title>
</head>
<form name="en" action="#" method="post">
<h1>Encryption</h1>
Plain Text<input type="text" name="encode" id="encode" />
key<input type="text" name="key" id="key" maxlength="5"/>
<input type="submit" name="submit" id="submit" value="Encryption"/>
<!--------------------------------------------------->
<?php
if (isset($_POST['submit'])) {
$key = $_POST['key'];
$string = $_POST['encode']; // note the spaces
$arraytKey=array();
$alphanumeric = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',0,1,2,3,4,5,6,7,8,9);
$key1 = (int)$key[0] -48;
$key2 = (int)$key[1] -48;
$key3 = (int)$key[2] -48;
$k = (int)$key1 * $key3 - $key2;
$i = (int)0;
$j = (int)0;
do{
if((int)$string[$i] == $alphanumeric[$j])
{
if(($j + $k) < strlen($alphanumeric))
{
$encode += strlen($alphanumeric[$j + $k]);
$i++;
$j = 0;
}
else
{
$x = (int)$j + $k;
$x = $x - strlen($alphanumeric);
$encode += $alphanumeric[$x];
$i++;
$j = 0;
}
}
else
$j++;
}while($i < (int)$string);
}
?>
<br><br>Cipher Text = <?=@$encode?>
</form>
<body>
</body>
</html>
Tag : PHP, HTML/CSS, JavaScript

|
|
 |
 |
 |
 |
Date :
2014-03-13 18:21:08 |
By :
pasatika |
View :
987 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 05
|