Cryptography Application Block 提供加密功能,主要內容:
- 簡介:支援 Hash(單向)與 Symmetric(雙向)兩種加密,並可自訂演算法
- 配置:以 Symmetric Encryption Provider 為例
- 資料加密
- 資料解密
- 取得 Hash 值
- 依 Hash 值驗證資料是否異動
適用情境
- 僅需加密、不需解密(如密碼儲存) → 使用 Hash Provider
- 需加密又需解密(如 URL 參數傳遞) → 使用 Symmetric Encryption Provider
開發效益
- 輕鬆解決應用程式加密需求
- 統一企業應用程式加密標準
- 可擴充:支援自訂加密演算法
配置步驟
- 開啟 Enterprise Library Configuration Tool(安裝目錄
bin 下的 EntLibConfig.exe)
- 選擇
File → Open Application,開啟專案的 App.config

後續新增 Cryptography Application Block,選擇 Provider 類型並設定金鑰等參數即可。