使用crypt加解密

如果有一個資料夾"test"
這邊用test1234來作為密碼

加密: crypt yourpassword<archive-no-encode.tgz>archive-ecoded.tgz

$ tar -vczf test.tgz  test
$ crypt  test1234<test.tgz>test2.tgz

這樣會產生一個test2.tgz的檔案(原test.tgz可以移除了)
這個時候test2.tgz就已經加密了
如果欲對test2.tgz直接解壓縮,會出現下面錯誤訊息

# tar -xzf test2.tgz 
gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error is not recoverable: exiting now

要解開的話:crypt yourpassword<archive-encoded.tgz>archive-decoded.tgz

crypt test1234<test2.tgz>test.tgz

這個網誌中的熱門文章

Bash判斷參數是否存在

Node.js package : forever