隨著網(wǎng)絡(luò)與計算機技術(shù)的發(fā)展,,數(shù)據(jù)存儲與數(shù)據(jù)交換的安全性已經(jīng)變得越來越重要,,加密技術(shù)已經(jīng)很早就用于數(shù)據(jù)存儲和數(shù)據(jù)交換。為了確保網(wǎng)絡(luò)數(shù)據(jù)交換時的雙方身份的正確性,,簽證體系也已經(jīng)成熟,。GPG就是用來加密數(shù)據(jù)與制作證書的一套工具。
GPG是一個完全免費,、源代碼公開,,并且與PGP完全兼容的軟件產(chǎn)品。GPG軟件作為用于加密和數(shù)字簽名的開放源碼工具,,許多Linux發(fā)行版本都自帶了該軟件,。在默認安裝的情況下,gpg會作為一個基本命令事先安裝好,。 如果選用的Linux發(fā)行版默認沒有安裝GPG,,可以通過tar包或RPM包進行安裝,可從http://www./download/下載安裝包,。 判斷是否安裝有GPG的方法也很簡單,。直接在命令行下輸入“gpg -h”命令,,如果系統(tǒng)已經(jīng)安裝有GPG,就會顯示關(guān)于GPG用法的信息,。 確定Linux系統(tǒng)中已經(jīng)安裝了GPG后,,就可以開始下面加密和簽名的工作了。 gpg文件加密解密步驟
生成密鑰
輸入用戶信息
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O >>確認OK
You need a Passphrase to protect your secret key. Enter passphrase: >>輸入密碼口令
Repeat passphrase:
生成密鑰過程
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. +++++.++++++++++>.++++++++++...........................................................+++++ >>生成密鑰過程會出現(xiàn)連續(xù)的這種符號,。 Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy! (Need 215 more bytes) We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. >>該信息提示用戶在系統(tǒng)上創(chuàng)建一些隨機的活動,,這個時候您可以多做些瑣事(像敲打鍵盤、移動
鼠標(biāo),、讀寫硬盤之類的),,這會讓隨機數(shù)字發(fā)生器有更好的機會獲得足夠的熵數(shù)。 gpg: /root/.gnupg/trustdb.gpg:trustdb created >>密鑰生成成功,!
public and secret key created and signed.
key marked as ultimately trusted. 查看.gnupg目錄下的公鑰文件,,提取生成的公鑰文件并導(dǎo)入到pubring.gpg中。
創(chuàng)建test.log加密測試文件,。
對test.log文件進行加密,。
對test.log.asc文件進行解密。
|
|