實(shí)驗(yàn):了解 HASH 算法的工作原理以及 md5sum 程序的使用
實(shí)驗(yàn)步驟:1、以 root 身份登錄到 linux 系統(tǒng)2、在根目錄下創(chuàng)建文件夾 md5testcd/mkdir md5test3、進(jìn)入 md5test 目錄:cd md5test4、創(chuàng)建名為 myfile 的文件:touch myfile5、使用 vi 編輯 myfile 文件,輸入以下內(nèi)容:Has anyone altered the contents of this file?6、使用 md5sum 計(jì)算 hash 校驗(yàn)和[root@md5test]#md5sum myfile7、再次運(yùn)行 md5sum 命令,并且將結(jié)果導(dǎo)出保存到 myfile.md5 文件中[root@md5test]md5sum myfile>myfile.md58、打開 myfile 文件,修改文件內(nèi)容(盡量作最小的改動(dòng))然后保存9、再次運(yùn)行 md5sum 命令,應(yīng)該得到以不同的 hash 值10、用 cat 命令查看 myfile.md5 內(nèi)容:cat myfile.md511、比較第 9 步和第 10 步的輸出結(jié)果,應(yīng)該看到兩者的不同12、輸入以下命令:md5sum/etc/passwd/>passwd.md5,創(chuàng)建針對(duì)當(dāng)前/etc/passwd數(shù)據(jù)庫(kù)的 hash 校驗(yàn)和13、查看 passwd.md5 文件內(nèi)容:cat passwd.md514、添加用戶 hashtest 并且修改密碼Linux#useradd hashtestLinux#passwd hashtestChanging password for user hashtestNes UNIX password:Retype new UNIX password:passwd:all authentication tokens updated successfully15、執(zhí)行命令 md5sum-c passwd.md5,其中-c 參數(shù)用來(lái)比較數(shù)據(jù)庫(kù)更改前后的 hash應(yīng)該能夠看到有關(guān)校驗(yàn)值已經(jīng)改變的信息