Class OdfEncryption
Provides the OdfEncryption API. 提供 OdfEncryption API。
public static class OdfEncryption
- Inheritance
-
OdfEncryption
- Inherited Members
Fields
Aes256AlgorithmUri
AES-256 加密演算法的識別 URI。
public const string Aes256AlgorithmUri = "http://www.w3.org/2001/04/xmlenc#aes256-cbc"
Field Value
Aes256GcmAlgorithmUri
AES-256-GCM 加密演算法的識別 URI。
public const string Aes256GcmAlgorithmUri = "http://www.w3.org/2009/xmlenc11#aes256-gcm"
Field Value
Argon2idDerivationUri
Argon2id 金鑰衍生函數的識別 URI。
public const string Argon2idDerivationUri = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#argon2id"
Field Value
BlowfishAlgorithmUri
Blowfish 加密演算法的識別 URI。
public const string BlowfishAlgorithmUri = "http://www.w3.org/2001/04/xmldsig-more#blowfish-cbc"
Field Value
OpenPgpAlgorithmUri
OpenPGP 加密演算法的識別 URI。
public const string OpenPgpAlgorithmUri = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0#openpgp"
Field Value
Methods
ByteArrayEquals(byte[]?, byte[]?)
Performs byte array equals. 比較兩個位元組陣列是否相等。
public static bool ByteArrayEquals(byte[]? a, byte[]? b)
Parameters
Returns
ComputeHash(byte[], string)
Computes hash. 計算資料的雜湊值。
public static byte[] ComputeHash(byte[] data, string checksumType)
Parameters
Returns
- byte[]
雜湊值位元組陣列
Decrypt(OdfPackage, string)
Performs the Decrypt operation. 解密指定 ODF 封裝中的所有加密專案。
public static void Decrypt(OdfPackage package, string password)
Parameters
packageOdfPackage要解密的 ODF 封裝執行個體
passwordstring解密密碼
DecryptEntry(byte[], string, string, string, int, int, byte[], byte[])
Short overload of DecryptEntry that accepts ciphertext, password, algorithmUri, derivationName, keySize, iterationCount, salt, and iv; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 ciphertext、password、algorithmUri、derivationName、keySize、iterationCount、salt 與 iv;其餘可選參數使用預設值並轉呼叫最長 DecryptEntry 多載。
public static byte[] DecryptEntry(byte[] ciphertext, string password, string algorithmUri, string derivationName, int keySize, int iterationCount, byte[] salt, byte[] iv)
Parameters
ciphertextbyte[]passwordstringalgorithmUristringderivationNamestringkeySizeintiterationCountintsaltbyte[]ivbyte[]
Returns
- byte[]
DecryptEntry(byte[], string, string, string, int, int, byte[], byte[], string?)
Short overload of DecryptEntry that accepts ciphertext, password, algorithmUri, derivationName, keySize, iterationCount, salt, iv, and startKeyGenName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 ciphertext、password、algorithmUri、derivationName、keySize、iterationCount、salt、iv 與 startKeyGenName;其餘可選參數使用預設值並轉呼叫最長 DecryptEntry 多載。
public static byte[] DecryptEntry(byte[] ciphertext, string password, string algorithmUri, string derivationName, int keySize, int iterationCount, byte[] salt, byte[] iv, string? startKeyGenName)
Parameters
ciphertextbyte[]passwordstringalgorithmUristringderivationNamestringkeySizeintiterationCountintsaltbyte[]ivbyte[]startKeyGenNamestring
Returns
- byte[]
DecryptEntry(byte[], string, string, string, int, int, byte[], byte[], string?, string?)
Short overload of DecryptEntry that accepts ciphertext, password, algorithmUri, derivationName, keySize, iterationCount, salt, iv, startKeyGenName, and kdfName; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 ciphertext、password、algorithmUri、derivationName、keySize、iterationCount、salt、iv、startKeyGenName 與 kdfName;其餘可選參數使用預設值並轉呼叫最長 DecryptEntry 多載。
public static byte[] DecryptEntry(byte[] ciphertext, string password, string algorithmUri, string derivationName, int keySize, int iterationCount, byte[] salt, byte[] iv, string? startKeyGenName, string? kdfName)
Parameters
ciphertextbyte[]passwordstringalgorithmUristringderivationNamestringkeySizeintiterationCountintsaltbyte[]ivbyte[]startKeyGenNamestringkdfNamestring
Returns
- byte[]
DecryptEntry(byte[], string, string, string, int, int, byte[], byte[], string?, string?, int)
Short overload of DecryptEntry that accepts ciphertext, password, algorithmUri, derivationName, keySize, iterationCount, salt, iv, startKeyGenName, kdfName, and argon2T; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 ciphertext、password、algorithmUri、derivationName、keySize、iterationCount、salt、iv、startKeyGenName、kdfName 與 argon2T;其餘可選參數使用預設值並轉呼叫最長 DecryptEntry 多載。
public static byte[] DecryptEntry(byte[] ciphertext, string password, string algorithmUri, string derivationName, int keySize, int iterationCount, byte[] salt, byte[] iv, string? startKeyGenName, string? kdfName, int argon2T)
Parameters
ciphertextbyte[]passwordstringalgorithmUristringderivationNamestringkeySizeintiterationCountintsaltbyte[]ivbyte[]startKeyGenNamestringkdfNamestringargon2Tint
Returns
- byte[]
DecryptEntry(byte[], string, string, string, int, int, byte[], byte[], string?, string?, int, int)
Short overload of DecryptEntry that accepts ciphertext, password, algorithmUri, derivationName, keySize, iterationCount, salt, iv, startKeyGenName, kdfName, argon2T, and argon2M; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 ciphertext、password、algorithmUri、derivationName、keySize、iterationCount、salt、iv、startKeyGenName、kdfName、argon2T 與 argon2M;其餘可選參數使用預設值並轉呼叫最長 DecryptEntry 多載。
public static byte[] DecryptEntry(byte[] ciphertext, string password, string algorithmUri, string derivationName, int keySize, int iterationCount, byte[] salt, byte[] iv, string? startKeyGenName, string? kdfName, int argon2T, int argon2M)
Parameters
ciphertextbyte[]passwordstringalgorithmUristringderivationNamestringkeySizeintiterationCountintsaltbyte[]ivbyte[]startKeyGenNamestringkdfNamestringargon2Tintargon2Mint
Returns
- byte[]
DecryptEntry(byte[], string, string, string, int, int, byte[], byte[], string?, string?, int, int, int)
Decrypts entry. 解密單一封裝項目。支援 PBKDF2 搭配 AES/Blowfish 以及 Argon2id 搭配 AES-GCM。
public static byte[] DecryptEntry(byte[] ciphertext, string password, string algorithmUri, string derivationName, int keySize, int iterationCount, byte[] salt, byte[] iv, string? startKeyGenName, string? kdfName, int argon2T, int argon2M, int argon2P)
Parameters
ciphertextbyte[]加密的密文資料位元組陣列
passwordstring解密密碼
algorithmUristring加密演算法的 XML 識別 URI
derivationNamestring金鑰衍生演算法的 XML 識別 URI
keySizeint金鑰大小(以位元組為單位)
iterationCountint金鑰衍生的反覆運算次數
saltbyte[]金鑰衍生的鹽值(Salt)位元組陣列
ivbyte[]加密的初始向量(IV)位元組陣列
startKeyGenNamestring初始金鑰產生的演算法名稱(選填)
kdfNamestring金鑰衍生函數的名稱(選填,例如 "argon2id")
argon2TintArgon2id 的時間複雜度/反覆運算次數(選填)
argon2MintArgon2id 的記憶體複雜度(單位為 KB,選填)
argon2PintArgon2id 的平行度/通道數(選填)
Returns
- byte[]
解密後的純文字資料位元組陣列
Encrypt(OdfPackage, string)
Short overload of Encrypt that accepts package and password; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 package 與 password;其餘可選參數使用預設值並轉呼叫最長 Encrypt 多載。
public static void Encrypt(OdfPackage package, string password)
Parameters
packageOdfPackagepasswordstring
Encrypt(OdfPackage, string, OdfEncryptionAlgorithm)
Performs the Encrypt operation. 加密指定 ODF 封裝中的所有適用專案。
public static void Encrypt(OdfPackage package, string password, OdfEncryptionAlgorithm algorithm)
Parameters
packageOdfPackage要加密的 ODF 封裝執行個體
passwordstring加密密碼
algorithmOdfEncryptionAlgorithm加密演算法,預設為 AES-256
EncryptEntry(byte[], string, OdfEncryptionAlgorithm, out byte[], out byte[], out byte[], int)
Encrypts entry. 加密單一封裝項目。支援傳統加密與 AES-GCM 加密,並產生對應的 IV、鹽值與驗證碼。
public static byte[] EncryptEntry(byte[] plaintext, string password, OdfEncryptionAlgorithm algorithm, out byte[] iv, out byte[] salt, out byte[] checksum, int iterationCount = 50000)
Parameters
plaintextbyte[]待加密的純文字資料位元組陣列
passwordstring加密密碼
algorithmOdfEncryptionAlgorithm加密演算法類型
ivbyte[]輸出參數,接收隨機產生的初始向量(IV)位元組陣列
saltbyte[]輸出參數,接收隨機產生的鹽值(Salt)位元組陣列
checksumbyte[]輸出參數,接收加密後計算出的驗證碼(Checksum)位元組陣列
iterationCountint金鑰衍生的反覆運算次數(預設為 50,000 次)
Returns
- byte[]
加密後的密文資料位元組陣列
Pbkdf2(byte[], byte[], int, int, string)
Performs pbkdf 2. 自訂實作以金鑰為基礎的金鑰衍生函式 PBKDF2,支援 SHA-1 與 SHA-256,確保跨平台行為一致。
public static byte[] Pbkdf2(byte[] password, byte[] salt, int iterations, int keyLength, string hashName)
Parameters
passwordbyte[]密碼位元組陣列
saltbyte[]鹽值位元組陣列
iterationsint反覆運算次數
keyLengthint衍生的金鑰長度
hashNamestring雜湊演算法名稱
Returns
- byte[]
衍生的金鑰位元組陣列