1
我想這個功能。第一個密碼 - 完美地工作,我驗證了它,但是當我解密時,它不符合這個詞。
有人能弄清楚爲什麼不起作用?腓str_ireplace不工作
// Polybius square 1 2 3 4 5 6 1 A Ă Â B C D 2 E F G H I Î 3 J K L M N O 4 P Q R S Ș T 5 Ț U V W X Y 6 Z . , ? - !
function cipher($text) {
$alphabet = array('a','ă','â','b','c','d','e','f','g','h','i','î','j','k','l','m','n','o','p','q','r','s','ș','t','ț','u','v','w','x','y','z','.',',','?','-','!');
$polybios = array('11','12','13','14','15','16','21','22','23','24','25','26','31','32','33','34','35','36','41','42','43','44','45','46','51','52','53','54','55','56','61','62','63','64','65','66');
$output = str_ireplace($alphabet, $polybios, $text);
return($output);
}
function decipher($string) {
$alphabet = array('a','ă','â','b','c','d','e','f','g','h','i','î','j','k','l','m','n','o','p','q','r','s','ș','t','ț','u','v','w','x','y','z','.',',','?','-','!');
$polybios array('11','12','13','14','15','16','21','22','23','24','25','26','31','32','33','34','35','36','41','42','43','44','45','46','51','52','53','54','55','56','61','62','63','64','65','66');
$output = str_ireplace($polybios, $alphabet, $string);
return($output);
}
$mesaj='cupcake';
$cipherText = cipher($mesaj);
echo $cipherText;
$decipherText = decipher($cipherText);
echo $decipherText;
我希望這個'cypher'是隻有約打,而不是你希望使用,以確保任何形式的通信 – Martin
的是什麼你的PHP錯誤日誌說些什麼? – Martin
究竟是什麼問題,爲什麼問題'str_ireplace'? – Martin