# 加密軟體工具

##### Linux

1. [Cryptsetup](https://gitlab.com/cryptsetup/cryptsetup) - 支援 LUKS/plain dm-crypt/loop-AES/TrueCrypt/BitLocker 等加密格式 
    - [How to Encrypt and Decrypt a Partition in Linux](https://www.linuxshelltips.com/encrypt-partition-linux/)
2. [eCryptFS](https://www.xmodulo.com/encrypt-files-directories-ecryptfs-linux.html)
3. [EncFS](https://www.makeuseof.com/tag/encrypt-dropbox-data-encfs-linux/)
4. [CryFS](https://www.cryfs.org/tutorial/)
5. [VeraCrypt](https://archive.codeplex.com/?p=veracrypt) - 跨平台支援，可移動至其他裝置。 
    - [How to Encrypt USB Drive on Linux Using VeraCrypt](https://www.linuxbabe.com/desktop-linux/encrypt-usb-drive-linux-using-veracrypt)

##### Windows

1. [AxCrypt](https://key.chtouch.com/ContentView.aspx?P=280)

##### 使用心得

<div id="bkmrk-%E5%AE%89%E8%A3%9D">安裝</div>- EncryptFS 輕易安裝在 CentOS 6.x
- EncFS 可以安裝在 CentOS 6，需透過 EPEL 安裝 fuse-encfs
- CryFS 只支援 Ubuntu

使用方法

<div id="bkmrk-%3Cencrypt-command%3E-%7E%2F">`<encrypt-command> ~/ENCRYPTED-DIR ~/DECRYPTED-DIR`</div><div id="bkmrk-"></div>- 三個軟體幾乎都用一樣的方式，需指定兩個目錄，加密目錄與解密目錄，其中解密目錄是用掛載的，實際檔案是以加密型態的檔案儲存在加密目錄內。
- 在加密目錄裡的檔案與資料夾都是以隨機亂數的名稱存在，檔案內容也都是亂數的隨意組合，要得知加密目錄內有什麼檔案與存取檔案內容，就必須經過解密。
- 加密目錄內的檔案解密步驟，作法三者幾乎一樣，都是透過解密目錄掛載方式，掛載成功後，解密目錄的存取就與一般正常目錄一樣。
- 解密目錄必須透過指令掛載後才能被使用，未被掛載前，這只是一個空目錄，而且不應該存取任何檔案。
- 解密所需的設定檔與加密資訊，三者各有所異。

<div id="bkmrk-%E6%87%89%E7%94%A8%E7%AF%84%E5%9C%8D">應用範圍</div>1. 個人雲端檔案加密。以 Dropbox 為例，將加密目錄設定為 Dropbox 的同步上傳目錄，解密目錄則為本地端的任何一個目錄，例如文件區。平常存取 dropbox 檔案都在文件區內作業，如此這些檔案實際被上傳到 Dropbox 雲端，是以加密型態檔案存在。
2. 檔案多人共用加密。將加密目錄設定在共用的 NFS 目錄（NAS），要存取的 Linux 工作站安裝加密軟體，然後將 NAS 上的加密目錄做解密掛載在本地端目錄，解密掛載時必須通過解密程序，至少會有一組密碼。

其他注意事項

同仁在存取解密目錄裡的檔案時，就與一般正常未加密目錄一樣，甚至可以將它們複製或下載，而複製後的檔案是呈現未加密型態。因此這類加密軟體不適合想避免敏感資料外流的作法。

##### GPG

驗證下載檔案的數位簽名檔

```
[root@db2v9 gpg]# tree
.
├── npp.7.8.8.Installer.exe
├── npp.7.8.8.Installer.exe.sig
└── nppGpgPub.asc

0 directories, 3 files
[root@db2v9 gpg]#
[root@db2v9 gpg]# gpg --verify npp.7.8.8.Installer.exe.sig npp.7.8.8.Installer.exe
gpg: Signature made Sun 28 Jun 2020 11:02:09 PM CST using RSA key ID 8D84F46E
gpg: Can't check signature: No public key

[root@db2v9 gpg]# gpg --import nppGpgPub.asc
gpg: key 8D84F46E: public key "Notepad++ <don.h@free.fr>" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
gpg: no ultimately trusted keys found

[root@db2v9 gpg]# gpg --verify npp.7.8.8.Installer.exe.sig npp.7.8.8.Installer.exe
gpg: Signature made Sun 28 Jun 2020 11:02:09 PM CST using RSA key ID 8D84F46E
gpg: Good signature from "Notepad++ <don.h@free.fr>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 14BC E436 2749 B2B5 1F8C  7122 6C42 9F1D 8D84 F46E
```

##### 延伸閱讀

- GPG 檔案加解密 
    - [Linux: HowTo Encrypt And Decrypt Files With A Password](https://www.cyberciti.biz/tips/linux-how-to-encrypt-and-decrypt-files-with-a-password.html)
    - [How to easily encrypt a file with GPG on Linux](https://linuxaria.com/howto/how-to-easily-encrypt-a-file-with-gpg-on-linux)
    - [Encrypting and decrypting files with password in Linux](https://www.blackmoreops.com/2015/05/07/encrypting-files-with-password/)
- 密碼保護 
    - [Linux: HowTo Encrypt And Decrypt Files With A Password](https://www.cyberciti.biz/tips/linux-how-to-encrypt-and-decrypt-files-with-a-password.html)
    - [7 Tools to Encrypt/Decrypt and Password Protect Files in Linux](https://www.tecmint.com/linux-password-protect-files-with-encryption/)
- LUKS  
    
    - [Implementing corporate laptop encryption using LUKS](https://www.redhat.com/en/blog/implementing-corporate-laptop-encryption-using-luks)
    - [How to unlock LUKS using Dropbear SSH keys remotely in Linux - nixCraft (cyberciti.biz)](https://www.cyberciti.biz/security/how-to-unlock-luks-using-dropbear-ssh-keys-remotely-in-linux/)