For PHP, SWIG generates a pasta.so
extension, which can be installed in
the system directory (for example, /etc/php/php.ini
), and must be enabled.
SWIG also generates a pasta.php
module file which loads the extension and
defines the API for libpasta
.
// In pasta_form.php
<?php
include("pasta.php");
$password = $_POST['password'];
$hash = pasta::hash_password("hello123");
if (pasta::verify_password($hash, $password)) {
echo "Correct password.";
} else {
echo "Sorry, that is incorrect";
}
?>
<html>
<head>
<title>libpasta PHP example</title>
</head>
<body>
<form action="pasta_form.php" method="post">
<p>Please enter yor password (hint: hello123) <input type="password" name="password" /></p>
<p><input type="submit" /></p>
</form>
</body>
</html>