Étape 2: Code PHP
Ce code est pour un php basé web app. Les fichiers projet sont attachés. Voir qu'un exemple sur chaque actualisation php génère un nouveau jeu de clés d’ordinateur.
function random_string() {$character_set_array = array() ; $character_set_array [] = array ('count' = > 10, "personnages" = > "abcdefghijklmnopqrstuvwxyz"); [$character_set_array] = array ('count' = > 2, 'caractères' = > "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); [$character_set_array] = array ('count' = > 2, 'caractères' = > "0123456789"); $character_set_array [] = array ('count' = > 2, 'caractères' = > '! $temp_array = array() ; foreach ($character_set_array as $character_set) {pour ($i = 0; $i < $character_set ["count"]; $i ++) {[$temp_array] = $character_set ['caractères'] [rand (0 strlen($character_set['characters']) - 1)] ; shuffle($temp_array)}} ; Return implode('', $temp_array) ; }
$validationKeylength = 128 ; $max = ceil($validationKeylength / 40) ; $random = '' ; pour ($i = 0; $i < $max ; $i ++) {$random. = sha1(microtime(true).mt_rand(10000,90000).random_string());} $validationKey = substr ($aléatoire, 0, $validationKeylength) ;
$decryptionKeylength = 64 ; $max = ceil($decryptionKeylength / 40) ; $random = '' ; pour ($i = 0; $i < $max ; $i ++) {$random. = sha1(microtime(true).mt_rand(10000,90000).random_string());} $decryptionKey = substr ($aléatoire, 0, $decryptionKeylength);? >