<?php
$translator = new i10n();
if ( ! isset( $_POST['STRING'] ) ) {
$_POST['STRING'] = '';
}
$output = '';
if ( ! empty( $_POST['STRING'] ) and
$_POST['STRING'] and
! empty( $_POST['trimString'] ) ) {
$_POST['STRING'] = trim( $_POST['STRING'] );
}
if ( defined( 'PASSWORD_BCRYPT' ) ) {
$arrPHPMethods[] = 'PASSWORD_BCRYPT';
$arrPHPMmethods['PASSWORD_BCRYPT'] = PASSWORD_BCRYPT;
}
if ( defined( 'PASSWORD_ARGON2I' ) ) {
$arrPHPMethods[] = 'PASSWORD_ARGON2I';
$arrPHPMmethods['PASSWORD_ARGON2I'] = PASSWORD_ARGON2I;
}
if ( defined( 'PASSWORD_ARGON2ID' ) ) {
$arrPHPMethods[] = 'PASSWORD_ARGON2ID';
$arrPHPMmethods['PASSWORD_ARGON2ID'] = PASSWORD_ARGON2ID;
}
$arrPHPOpenSSLMethods = openssl_get_md_methods();
$arrUnixSSLMethods = false;
if ( '' != trim( `which openssl`
) ) {
$arrUnixSSLMethods = getOpenSSLDigests();
}
$arrCryptMethods = [];
if ( defined( 'CRYPT_STD_DES' ) and
1 == CRYPT_STD_DES
) $arrCryptMethods[] = 'STD_DES';
if ( defined( 'CRYPT_EXT_DES' ) and
1 == CRYPT_EXT_DES
) $arrCryptMethods[] = 'EXT_DES';
if ( defined( 'CRYPT_MD5' ) and
1 == CRYPT_MD5
) $arrCryptMethods[] = 'MD5';
if ( defined( 'CRYPT_BLOWFISH' ) and
1 == CRYPT_BLOWFISH
) {
$arrCryptMethods[] = 'BLOWFISH-2a';
$arrCryptMethods[] = 'BLOWFISH-2x';
$arrCryptMethods[] = 'BLOWFISH-2y';
}
if ( defined( 'CRYPT_SHA256' ) and
1 == CRYPT_SHA256
) $arrCryptMethods[] = 'SHA-256';
if ( defined( 'CRYPT_SHA512' ) and
1 == CRYPT_SHA512
) $arrCryptMethods[] = 'SHA-512';
$arrOtherMethods[] = 'PHP-md5()';
$arrOtherMethods[] = 'PHP-sha1()';
$arrOtherMethods[] = 'Old Unix passwd';
$arrOtherMethods[] = 'Old Unix passwd ($1$)';
$arrOtherMethods[] = 'Old Apache <= 2.2';
$arrOtherMethods[] = 'Apache > 2.2';
$arrOtherMethods[] = 'Old MySQL-passwd()';
filter_var( $arrPHPMethods, FILTER_SANITIZE_FULL_SPECIAL_CHARS
);
$selectorPHP = '<legend for="PHPMethode">' . $translator -> get('PHP-password_hash()-methods') . ':</legend><select onchange="clearHash();" id="PHPMethode" name="PHPMethode">' . PHP_EOL . '<option value="">' . $translator -> get('None of them') . '</option>' . PHP_EOL ;
foreach ( $arrPHPMethods as $sMethod ) {
if ( isset( $_POST['PHPMethode'] ) and
$_POST['PHPMethode'] == $sMethod ) {
$selectorPHP .= '<option selected="selected" value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
} else {
$selectorPHP .= '<option value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
}
}
$selectorPHP .= '</select>' . PHP_EOL;
filter_var( $arrPHPOpenSSLMethods, FILTER_SANITIZE_FULL_SPECIAL_CHARS
);
$selectorPHPOpenSSL = '<legend for="PHPOpenSSLMethode">' . $translator -> get('PHP-openssl_digest() and output translating') . ':</legend><select onchange="clearHash();" id="PHPOpenSSLMethode" name="PHPOpenSSLMethode">' . PHP_EOL . '<option value="">' . $translator -> get('None of them') . '</option>' . PHP_EOL ;
foreach ( $arrPHPOpenSSLMethods as $sMethod ) {
if ( isset( $_POST['PHPOpenSSLMethode'] ) and
$_POST['PHPOpenSSLMethode'] == $sMethod ) {
$selectorPHPOpenSSL .= '<option selected="selected" value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
} else {
$selectorPHPOpenSSL .= '<option value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
}
}
$selectorPHPOpenSSL .= '</select>' . PHP_EOL;
$outputmethod = '<select onchange="clearHash();" name="outputMethodPHPOpenSSL">
<option value="hex">hexadecimal</option>
';
if ( isset( $_POST['outputMethodPHPOpenSSL'] ) and
$_POST['outputMethodPHPOpenSSL'] == 'base64' ) {
$PHPOpenSSLbase64 = true;
$outputmethod .= '<option selected="selected" value="base64">base64</option>';
} else {
$outputmethod .= '<option value="base64">base64</option>';
$PHPOpenSSLbase64 = false;
}
$outputmethod .= '
</select>
';
$selectorPHPOpenSSL .= $outputmethod;
if ( $arrUnixSSLMethods ) {
filter_var( $arrUnixSSLMethods, FILTER_SANITIZE_FULL_SPECIAL_CHARS
);
$selectorUnixOpenSSL = '<legend for="UnixOpenSSLMethode">' . $translator -> get('Unix-OpenSSL') . ':</legend><select onchange="clearHash();" id="UnixOpenSSLMethode" name="UnixOpenSSLMethode">' . PHP_EOL . '<option value="">' . $translator -> get('None of them') . '</option>' . PHP_EOL ;
foreach ( $arrUnixSSLMethods as $sMethod ) {
if ( isset( $_POST['UnixOpenSSLMethode'] ) and
$_POST['UnixOpenSSLMethode'] == $sMethod ) {
$selectorUnixOpenSSL .= '<option selected="selected" value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
} else {
$selectorUnixOpenSSL .= '<option value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
}
}
$selectorUnixOpenSSL .= '</select>' . PHP_EOL;
$outputmethod = '<select onchange="clearHash();" name="outputMethodUnixOpenSSL">
<option value="hex">hexadecimal</option>
';
if ( isset( $_POST['outputMethodUnixOpenSSL'] ) and
$_POST['outputMethodUnixOpenSSL'] == 'base64' ) {
$outputmethod .= '<option selected="selected" value="base64">base64</option>';
$UnixOpenSSLbase64 = true;
} else {
$outputmethod .= '<option value="base64">base64</option>';
$UnixOpenSSLbase64 = false;
}
$outputmethod .= '</select>' . PHP_EOL;
$selectorUnixOpenSSL .= $outputmethod;
}
filter_var( $arrCryptMethods, FILTER_SANITIZE_FULL_SPECIAL_CHARS
);
$selectorCrypt = '<legend for="CryptMethode">' . $translator -> get('PHP-crypt()-methods') . ':</legend><select onchange="clearHash();" id="CryptMethode" name="CryptMethode">' . PHP_EOL . '<option value="">' . $translator -> get('None of them') . '</option>' . PHP_EOL ;
foreach ( $arrCryptMethods as $sMethod ) {
if ( isset( $_POST['CryptMethode'] ) and
$_POST['CryptMethode'] == $sMethod ) {
$selectorCrypt .= '<option selected="selected" value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
} else {
$selectorCrypt .= '<option value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
}
}
$selectorCrypt .= '</select>' . PHP_EOL;
filter_var( $arrOtherMethods, FILTER_SANITIZE_FULL_SPECIAL_CHARS
);
$selectorOther = '<legend for="OtherMethode">' . $translator -> get('Other Methods') . ':</legend><select onchange="clearHash();" id="OtherMethode" name="OtherMethode">' . PHP_EOL . '<option value="">' . $translator -> get('None of them') . '</option>' . PHP_EOL ;
foreach ( $arrOtherMethods as $sMethod ) {
if ( isset( $_POST['OtherMethode'] ) and
$_POST['OtherMethode'] == $sMethod ) {
$selectorOther .= '<option selected="selected" value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
} else {
$selectorOther .= '<option value="' . $sMethod . '">' . $sMethod . '</option>' . PHP_EOL;
}
}
$selectorOther .= '</select>' . PHP_EOL;
if ( ! empty ( $_POST['PHPMethode'] ) ) {
if ( isset( $_POST['STRING'] ) and
$_POST['STRING'] ) {
$string = password_hash($_POST['STRING'], $arrPHPMmethods[$_POST['PHPMethode']] );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
}
}
if ( ! empty ( $_POST['PHPOpenSSLMethode'] ) ) {
if ( isset( $_POST['STRING'] ) and
$_POST['STRING'] ) {
if ( $PHPOpenSSLbase64 ) {
$string = base64_encode( openssl_digest
( $_POST['STRING'], $_POST['PHPOpenSSLMethode'], true ) );
} else {
$string = openssl_digest( $_POST['STRING'], $_POST['PHPOpenSSLMethode'], false );
}
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
}
}
if ( ! empty ( $_POST['UnixOpenSSLMethode'] ) ) {
if ( isset( $_POST['STRING'] ) and
$_POST['STRING'] ) {
$string = getOpenSSLHash( $_POST['STRING'], $_POST['UnixOpenSSLMethode'], false );
if ( $UnixOpenSSLbase64 ) {
}
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
}
}
if ( ! empty( $_POST['CryptMethode'] ) ) {
if ( isset( $_POST['STRING'] ) and
$_POST['STRING'] ) {
if ( 'STD_DES' == $_POST['CryptMethode'] ) {
$salt = mkSalt( 2 );
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'EXT_DES' == $_POST['CryptMethode'] ) {
$salt = '_' . mkSalt(8 );
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'MD5' == $_POST['CryptMethode'] ) {
$salt = '$1$' . mkSalt( 9 );
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'BLOWFISH-2a' == $_POST['CryptMethode'] ) {
$salt = '$2a$10$' . mkSalt();
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'BLOWFISH-2x' == $_POST['CryptMethode'] ) {
$salt = '$2x$10$' . mkSalt();
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'BLOWFISH-2y' == $_POST['CryptMethode'] ) {
$salt = '$2y$10$' . mkSalt();
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'SHA-256' == $_POST['CryptMethode'] ) {
$salt = '$5$rounds=65536$' . mkSalt();
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'SHA-512' == $_POST['CryptMethode'] ) {
$salt = '$6$rounds=65536$' . mkSalt(22 );
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
}
}
}
if ( ! empty( $_POST['OtherMethode'] ) ) {
if ( isset( $_POST['STRING'] ) and
$_POST['STRING'] ) {
if ( 'PHP-md5()' == $_POST['OtherMethode'] ) {
$string = md5( $_POST['STRING'] );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'PHP-sha1()' == $_POST['OtherMethode'] ) {
$string = sha1( $_POST['STRING'] );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'Old Unix passwd' == $_POST['OtherMethode'] ) {
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( `
$sys`
) . '</output>';
} elseif ( 'Old Unix passwd ($1$)' == $_POST['OtherMethode'] ) {
$salt = mkSalt( 3 );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( `
$sys`
) . '</output>';
} elseif ( 'Old Apache <= 2.2' == $_POST['OtherMethode'] ) {
$h = new APR1_MD5();
$string = $h -> hash( $_POST['STRING'] );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . $string . '</output>';
} elseif ( 'Apache > 2.2' == $_POST['OtherMethode'] ) {
$salt = '$2y$05$' . mkSalt();
$string = crypt( $_POST['STRING'], $salt );
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} elseif ( 'Old MySQL-passwd()' == $_POST['OtherMethode'] ) {
$output = '<h2>' . $translator -> get('Output') . ':</h2><output id="hash">' . htmlentities( $string ) . '</output>';
} else {
trigger_error("Methode: " . $_POST['OtherMethode'], E_USER_WARNING );
}
}
}
class APR1_MD5 {
const BASE64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const APRMD5_ALPHABET = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
// Source/References for core algorithm:
// http://www.cryptologie.net/article/126/bruteforce-apr1-hashes/
// http://svn.apache.org/viewvc/apr/apr-util/branches/1.3.x/crypto/apr_md5.c?view=co
// http://www.php.net/manual/en/function.crypt.php#73619
// http://httpd.apache.org/docs/2.2/misc/password_encryptions.html
// Wikipedia
public static
function hash($mdp, $salt = null) {
$salt = self::salt();
$context = $mdp.'$apr1$'.$salt;
$binary = pack('H32', md5($mdp.$salt.$mdp));
for($i=$max; $i>0; $i-=16)
for($i=$max; $i>0; $i>>=1)
$context .= ($i & 1) ?
chr(0) : $mdp[0];
$binary = pack('H32', md5($context));
for($i=0; $i<1000; $i++) {
$new = ($i & 1) ? $mdp : $binary;
if($i % 3) $new .= $salt;
if($i % 7) $new .= $mdp;
$new .= ($i & 1) ? $binary : $mdp;
}
$hash = '';
for ($i = 0; $i < 5; $i++) {
$k = $i+6;
$j = $i+12;
if($j == 16) $j = 5;
$hash = $binary[$i].$binary[$k].$binary[$j].$hash;
}
$hash = chr(0).chr(0).$binary[11].$hash;
self::BASE64_ALPHABET,
self::APRMD5_ALPHABET
);
return '$apr1$' . $salt . '$'. $hash;
}
// 8 character salts are the best. Don't encourage anything but the best.
public static function salt() {
$alphabet = self::APRMD5_ALPHABET;
$salt = '';
for($i=0; $i<8; $i++) {
$salt .= $alphabet[$offset];
}
return $salt;
}
}
class i10n {
private $arr;
private $lang = 'de';
function __construct() {
if ( isset( $_COOKIE['lang'] ) ) {
$this-> lang = $_COOKIE['lang'];
} else {
if ( isset ( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
$arTmp = explode( ',' , $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
foreach ( $arTmp as $item ) {
$arLangQuote = explode( ';', $item );
if ( ! isset($arLangQuote[1] ) ) {
$arLangQuote[1] = 1;
}
$arLangQuote[0] = trim( $arLangQuote[0] );
if ( $arLangQuote[0] ) {
$arAcceptedLanguages[] = $arT;
}
}
$quote = 0;
$lang='';
foreach ( $arAcceptedLanguages as $l ) {
if ( $l['quote'] > $quote ) {
$quote = $l['quote'];
$lang = $l['lang'];
}
}
} else {
$this-> lang = 'en';
}
}
$s = 'Password hash generator';
$this -> arr[$s]['de'] = 'Passwort-Hash-Generator';
$this -> arr[$s]['fr'] = 'Password-hash generateur';
$s = 'This website contains a comprehensive form. Javascript is required for this to work.';
$this -> arr[$s]['de'] = 'Diese Webseite enthält ein umfangreiches Formular. Damit dieses bedienbar ist wird Javascript benötigt.';
$this -> arr[$s]['fr'] = 'Ce site contient un formulaire complet. Javascript est requis pour que cela fonctionne.';
$s='Select your language';
$this -> arr[$s]['de'] = 'Wählen Sie Ihre Sprache';
$this -> arr[$s]['fr'] = 'Sélectioné votre language';
$s='Please choose the method first';
$this -> arr[$s]['de'] = 'Bitte wählen Sie erst die Methode';
$this -> arr[$s]['fr'] = 'S\'il vous plaît choisir la méthode d\'abord';
$s = 'With this tool you can generate password hashes for different systems. This is useful if you forget a password but can access the appropriate files.';
$this -> arr[$s]['de'] = 'Mit diesem Tool können Sie Passwort-Hashes für verschiedene Systeme generieren. Das dann nützlich, wenn man ein Passwort ein vergesssen hat aber auf die passenden Dateien schreiben zugreifen kann.';
$this -> arr[$s]['fr'] = 'Avec cet outil, vous pouvez générer des hachages de mots de passe pour différents systèmes. Ceci est utile si vous oubliez un mot de passe mais pouvez accéder aux fichiers appropriés.';
$s = 'Data protection';
$this -> arr[$s]['de'] = 'Datenschutz';
$this -> arr[$s]['fr'] = 'Politique de confidentialité';
$s = 'Your IP address will be stored for a maximum of 2 weeks. A cookie is only set if you choose a language. When the browser is finished it will be forgotten. The data entered by you are processed but not stored at all.';
$this -> arr[$s]['de'] = 'Ihre IP-Adresse wird höchstens 2 Wochen gespeichert. Ein Cookie wird nur gesetzt wenn Sie eine Sprache wählen. Bei Beendigung des Browsers wird es vergessen. Die von Ihnen eingegeben Daten werden zwar verarbeitet aber gar nicht gespeichert.';
$this -> arr[$s]['fr'] = 'Votre adresse IP sera enregistrée pendant 2 semaines maximum. Un cookie n\'est défini que si vous choisissez une langue. Lorsque le navigateur est terminé, il sera oublié. Les données que vous avez entrées sont traitées mais pas stockées du tout.';
$s = 'You can also <a href="https://code.fastix.org/Projekte/PHP%3Apassword-hash-generator/">download this script</a> and install it yourself.';
$this -> arr[$s]['de'] = 'Sie können <a href="https://code.fastix.org/Projekte/PHP%3Apassword-hash-generator/">dieses Skript auch herunterladen</a> und selbst installieren.';
$this -> arr[$s]['fr'] = 'Vous pouvez également <a href="https://code.fastix.org/Projekte/PHP%3Apassword-hash-generator/">télécharger ce script</a> et l\'installer vous-même.';
$s = 'Select the method';
$this -> arr[$s]['de'] = 'Auswahl der Methode';
$this -> arr[$s]['fr'] = 'Sélectioné de la méthode';
$s = 'Selection of the algorithm';
$this -> arr[$s]['de'] = 'Auswahl des Algorithmus';
$this -> arr[$s]['fr'] = 'Sélection de l\'algorithme';
$s = 'PHP-password_hash()-methods';
$this -> arr[$s]['de'] = 'PHP-password_hash()-Methoden';
$this -> arr[$s]['fr'] = 'Le methods de PHP-password_hash()';
$s = 'PHP-crypt()-methods';
$this -> arr[$s]['de'] = 'PHP-crypt()-Methoden';
$this -> arr[$s]['fr'] = 'Le methods de PHP-crypt()';
$s = 'PHP-openssl_digest() and output translating';
$this -> arr[$s]['de'] = 'PHP-OpenSSL-Methoden / Ausgabe-Form';
$this -> arr[$s]['fr'] = 'Le methods de PHP-OpenSSL et procédé d\'émission';
$s = 'Unix-openssl_digest() and output translating';
$this -> arr[$s]['de'] = 'Unix-OpenSSL-Methoden / Ausgabe-Form';
$this -> arr[$s]['fr'] = 'Le methods de Unix-OpenSSL et procédé d\'émission';
$s = 'Other Methods';
$this -> arr[$s]['de'] = 'Andere Methoden';
$this -> arr[$s]['fr'] = 'Autres méthodes';
$s = 'None of them';
$this -> arr[$s]['de'] = 'Keine davon';
$this -> arr[$s]['fr'] = 'Rien de ça';
$s = 'Enter the password';
$this -> arr[$s]['de'] = 'Eingabe des Passwortes';
$this -> arr[$s]['fr'] = 'Entrez le mot de passe';
$s = 'Password';
$this -> arr[$s]['de'] = 'Passwort';
$this -> arr[$s]['fr'] = 'Le mot de passe';
$s = 'Generate';
$this -> arr[$s]['de'] = 'Generiere';
$this -> arr[$s]['fr'] = 'générer';
$s = 'Output';
$this -> arr[$s]['de'] = 'Ausgabe';
$this -> arr[$s]['fr'] = 'Résultat';
$s = 'Remove all <q>white spaces</q> at begin an end of this string';
$this -> arr[$s]['de'] = 'Entferne alle <q>white spaces</q> am Beginn und am Ende';
$this -> arr[$s]['fr'] = 'Supprimer tous les <q>espaces blancs</q> au début et à la fin';
}
public function get( $s ) {
if ( isset($this -> arr[ $s ][ $this -> lang ] ) ) {
return $this -> arr[ $s ][ $this -> lang ];
} else {
return $s;
}
}
}
function mksalt($l=22, $s='0123456789abcdefghijklmnopqrstyuvwxyzABCDEFGHIJKLMNOPQRSTYUVWXYZ./') {
$salt = '';
for ( $i=0; $i<$l; $i++ ) {
$p = random_int( 0, $len - 1 );
$salt .= $s[$p];
}
return $salt;
}
function getOpenSSLDigests() {
$rows = explode("\n", `openssl help
2>&1`
);
$firstLine = false;
$lastLine = false;
for ( $i = 0; $i < sizeof( $rows ); $i++ ) {
$row = trim( $rows[$i] );
if ( false === $firstLine and
false !== strpos( $row, 'Message Digest commands' ) ) {
$firstLine = $i + 1;
}
if ( false != $firstLine and '' == $row ) {
$lastLine = $i - 1;
break;
}
}
if ( 0 == $firstLine ) return false;
$s = "";
for ( $i = $firstLine; $i <= $lastLine; $i++ ) {
$s .= $rows[$i] . " ";
}
return $arr;
}
function getOpenSSLHash( $string, $digest ) {
}
function getOldUnixPasswordHash ( $string ) {
$sys = 'export LANG=en_US.UTF-8; echo ' . escapeshellarg( $string ) . ' | openssl passwd stdin';
}
?><!DOCTYPE html>
<html>
<head>
<title><?=$translator -> get('Password hash generator'); ?></title>
<link rel="stylesheet" href="/standard.css" type="text/css">
<style>
#content { padding: 0rem 1rem 0rem 1rem; }
fieldset { margin-bottom:1rem; }
legend { font-weight:bold; }
output { border:1px solid black; padding: .5rem; }
#STRING { width: calc(100% - 3rem); }
#languageSselector { position:absolute;top:.75rem; right:1rem; text-align:right; }
</style>
<script>
function fShow(formPart) {
document.getElementById('selectedMethod').innerHTML=document.getElementById(formPart).innerHTML;
clearHash();
}
function clearHash() {
if ( document.getElementById('hash') ) {
document.getElementById('hash').innerHTML='';
}
}
</script>
</head>
<header>
<h1><?=$translator -> get('Password hash generator'); ?></h1>
</header>
<noscript><strong>Hm. <?=$translator -> get('This website contains a comprehensive form. Javascript is required for this to work.');?></strong></noscript>
<div id="content" style="display:none">
<p><?=$translator -> get('With this tool you can generate password hashes for different systems. This is useful if you forget a password but can access the appropriate files.'); ?></p>
<p><strong><?=$translator -> get('Data protection');?>:</strong> <?=$translator -> get('Your IP address will be stored for a maximum of 2 weeks. A cookie is only set if you choose a language. When the browser is finished it will be forgotten. The data entered by you are processed but not stored at all.');?> <?=$translator -> get('You can also <a href="https://code.fastix.org/Projekte/PHP%3Apassword-hash-generator/">download this script</a> and install it yourself.'); ?></p>
<div id="languageSselector"><?=$translator -> get('Select your language'); ?>:
<button onclick="document.cookie='lang=en'; location.reload()">en</button>
<button onclick="document.cookie='lang=de'; location.reload()">de</button>
<button onclick="document.cookie='lang=fr'; location.reload()">fr</button>
</div>
<h2>1. <?=$translator -> get('Select the method'); ?></h2>
<button onclick="fShow('selectorPHP'); return false"><?=$translator -> get('PHP-password_hash()-methods') ;?></button>
<button onclick="fShow('selectorCrypt'); return false"><?=$translator -> get('PHP-crypt()-methods') ;?></button>
<button onclick="fShow('selectorPHPOpenSSL'); return false"><?=$translator -> get('PHP-openssl_digest() and output translating') ;?></button>
<button onclick="fShow('selectorUnixOpenSSL'); return false"><?=$translator -> get('Unix-openssl_digest() and output translating') ;?></button>
<button onclick="fShow('selectorOthers'); return false"><?=$translator -> get('Other Methods') ;?></button>
<form name="methods" method="POST">
<h2>2. <?=$translator -> get('Selection of the algorithm'); ?>:</h2>
<fieldset id="selectedMethod">
<?php
if ( isset($_POST['PHPMethode'] ) ) {
echo $selectorPHP;
} elseif ( isset($_POST['CryptMethode'] ) ) {
echo $selectorCrypt;
} elseif ( isset($_POST['PHPOpenSSLMethode'] ) ) {
echo $selectorPHPOpenSSL;
} elseif ( isset($_POST['UnixOpenSSLMethode'] ) ) {
echo $selectorUnixOpenSSL;
} elseif ( isset($_POST['OtherMethode'] ) ) {
echo $selectorOther;
} else {
echo '<p>' . $translator -> get('Please choose the method first') . '</p>';
}
?>
</fieldset>
<h2>3. <?=$translator -> get('Enter the password'); ?>:</h2>
<fieldset>
<legend for="STRING"><?=$translator -> get('Password'); ?>:</legend>
<input oninput="clearHash();" onkeydown="clearHash();" onchange="clearHash();" type="text" id="STRING" name="STRING" value="
<?=htmlspecialchars( $_POST['STRING'] );?>"><br>
<?php if (! empty( $_POST['trimString'] ) ) { ?>
<input onchange="clearHash();" type="checkbox" checked="checked" name="trimString"> <?=$translator -> get('Remove all <q>white spaces</q> at begin an end of this string'); ?>
<?php } else { ?>
<input onchange="clearHash();" type="checkbox" name="trimString"> <?=$translator -> get('Remove all <q>white spaces</q> at begin an end of this string'); ?>
<?php } ?>
</fieldset>
<button onclick="clearHash()"><?=$translator -> get('Generate'); ?></button>
<?=$output; ?>
</form>
</div>
<form id="hiddenFormParts" style="display:none;">
<div id="selectorPHP">
<?=$selectorPHP; ?>
</div>
<div id="selectorCrypt">
<?=$selectorCrypt; ?>
</div>
<div id="selectorPHPOpenSSL">
<?=$selectorPHPOpenSSL; ?>
</div>
<div id="selectorUnixOpenSSL">
<?=$selectorUnixOpenSSL; ?>
</div>
<div id="selectorOthers">
<?=$selectorOther; ?>
</div>
</form>
</div>
<script>
document.getElementById('content').style.display="block";
</script>
</body>
</html>