對于一個簡單的郵件列表,我將數據存儲在.txt文件中。在 txt 文件中有 5 行。其中 2 個(包含姓名和電子郵件)已加密。出于安全原因,我存儲了加密的姓名和電子郵件。這就是我搜索文件的方式:/* EMAIL SEARCH */$email_search = $_GET['email_search']; // get string from url for searchif (isset($email_search)) { $searchthis = strtolower($email_search); $email_matches = array(); $files = glob("subscribers/*.txt"); // Specify the file directory by extension (.txt) foreach($files as $file) { // Loop the files in the directory { $handle = @fopen($file, "r"); if ($handle) { $lines = file($file); $grab_email = strtolower($lines[3]); // for sorting only while (!feof($handle)) { $buffer = fgets($handle); if(strpos(strtolower($buffer), $searchthis) !== FALSE) // strtolower; search word not case sensitive $email_matches[$file] = $grab_email; // put all lines in array indexed by email } fclose($handle); } }}asort($email_matches);<!-- search form --><form class="search-form form-inline" action="admin.php" method="GET"> <div class="input-group mb-3"> <input class="form-control" type="text" name="email_search" placeholder="Search for..." /> <div class="input-group-append"> <button class="btn btn-primary" type="submit">Search</button> </div> </div> </form>這是一個txt文件的樣子:id-5e0786c07c802 // idFriends //categoryygkKcL/jz9U= // name (encrypted)6gkKcL/jz9XuVRNayyIVcFbLw3ord0nc7IJj // email (encrypted)902d95a9bf1c3f59a3996e4e7b4dec79 // token以前,當數據未加密時,此搜索確實可以正常工作!但是,當每個文件中的名稱和電子郵件行被加密時,我現在如何搜索?
1 回答

FFIVE
TA貢獻1797條經驗 獲得超6個贊
使用加密值搜索呢?
在您的代碼中,$_GET['email_search']
包含您要搜索的單詞或值。我不知道您的加密方式如何,但您可以加密您正在搜索的單詞,例如:
$email_search = openssl_encrypt($_GET['email_search'], $ciphering, $encryption_key, $options, $encryption_iv); // get string from url for search
- 1 回答
- 0 關注
- 119 瀏覽
添加回答
舉報
0/150
提交
取消