「encryption」模組
encryption 模組提供一系列高階函式,用於資料保護和安全通訊。這個程式庫可簡化使用密碼衍生金鑰加密及解密字串的程序,並提供 S/MIME 電子郵件驗證和解密的專用處理方式,確保郵件完整性和機密性。
TIPCommon.encryption.decrypt
TIPCommon.encryption.decrypt(enc_data: bytes, key: str) → str
使用提供的密碼解密資料。
參數
| 參數 | |
|---|---|
enc_data |
bytes要解密的加密資料。 |
key |
str解密程序中用於產生金鑰的密碼。 |
傳回
解密後的訊息。
傳回類型
str
TIPCommon.encryption.decrypt_email
TIPCommon.encryption.decrypt_email(smime_email_config: SmimeEmailConfig, logger: ScriptLogger) → Message
檢查電子郵件是否經過加密或簽署,並執行必要的解密或驗證作業。
參數
| 參數 | |
|---|---|
smime_email_config |
SmimeEmailConfig
設定物件,內含電子郵件訊息 ( |
logger |
ScriptLogger
|
傳回
包含已解密或驗證內容的訊息物件。
傳回類型
email.message.Message
TIPCommon.encryption.encrypt
TIPCommon.encryption.encrypt(data: str, key: str) → bytes
使用提供的金鑰加密 JSON 字串。
參數
| 參數 | |
|---|---|
data |
str
要加密的 JSON 字串。 |
key |
str
加密程序中用來產生金鑰的密碼。 |
傳回
以位元組字串形式呈現的加密訊息。
傳回類型
bytes
TIPCommon.encryption.get_private_key
TIPCommon.encryption.get_private_key(password: str) → bytes
從提供的密碼衍生加密編譯金鑰。
參數
| 參數 | |
|---|---|
password |
str
用來產生私密金鑰的密碼字串。 |
傳回
代表衍生私密金鑰的位元組字串。
傳回類型
bytes