Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LAVANYA-PIDIKITI authored Apr 13, 2023
0 parents commit e1648b7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<form action="cc.php" method="POST">
text<input type="text" name="plaintext" id="plaintext">
key<input type="number" name="key" id="key">
<input type="submit" value="submit">
</form>
</body>
</html>
28 changes: 28 additions & 0 deletions cc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
function shiftAndReplace($input, $shift){
$output = "";
for ($i = 0 ; $i < strlen($input); $i++) {
$ch = $input[$i];
if (ctype_alpha($ch)) {
$base = ctype_upper($ch) ? 'A' : 'a';
$ch = chr(((ord($ch) - ord($base) + $shift) % 26 + 26) % 26 + ord($base));
if ($ch == 'a') {
$ch = 'z';
} else if ($ch == 'z') {
$ch = 'a';
}
}
$output .= $ch;
}
return $output;
}

function encrypt($input, $shift){
return shiftAndReplace($input, 26 - $shift);
}

$plaintext=$_POST['plaintext'];
$key=$_POST['key'];
$ciphertext=encrypt($plaintext,$key);
echo 'Ciphertext is: ' . $ciphertext;
?>

0 comments on commit e1648b7

Please sign in to comment.