tp2 finit

This commit is contained in:
2022-10-21 10:57:50 +02:00
parent 141fd0f1ef
commit a655ebe44d
10 changed files with 94 additions and 22 deletions

View File

@@ -1,15 +1,37 @@
<?php
$dl = false;
require('./config.php');
if(isset($_POST['Envoyer'])) {
if(!empty($_FILES['File'])) {
$fichier = $_FILES['File'];
$uploadDirectory = "./d/"; // fichier d'upload
$fileInfo = new SplFileInfo($_FILES['File']['name']); // préparation du fichier pour upload
$nouveauFichier = $fileInfo->getFilename();
$pathToSave = $uploadDirectory.$nouveauFichier;
move_uploaded_file($_FILES['File']['tmp_name'], $pathToSave);
openssl_sign(file_get_contents($pathToSave), $export, file_get_contents("./b/clePrivee"));
file_put_contents("./d/signature", $export);
$dl = true;
}
}
?>
<html>
<form method="POST" action="c.php">
<label for="Code">Fichier</label> <input id="File" name="File" value=""/><br />
<input type="submit" name="Envoyer" value="Envoyer" />
<form method="POST" action="d.php" enctype="multipart/form-data">
<label for="File">Fichier : </label><input type="file" id="File" name="File" value=""/><br />
<input id="Envoyer" type="submit" name="Envoyer" value="Envoyer" />
</form>
<p>Texte chiffré : <?php echo $ret?></p>
<p>Texte déchiffré : <?php echo $deret?></p>
<?php
if($dl) {
echo '<h2>Télécharger signature</h2>'
.'<a href ="./d/signature">Télécharger</a>';
}
?>
</html>