Microsoft Windows 2000及更高版本公开了Data Protection API(DPAPI),它为每个用户或每个系统的上下文加密数据.呼叫者不提供用于加密数据的密钥.而是使用从用户或系统凭证派生的密钥对数据进行加密.
此API通过ProtectedData类在.NET中方便地公开:
// Encrypts the data in a specified byte array and returns a byte array
// that contains the encrypted data.
public static byte[] Protect(
byte[] userData,
byte[] optionalEntropy,
DataProtectionScope scope
)
// Decrypts the data in a specified byte array and returns a byte array
// that contains the decrypted data.
public static byte[] Unprotect(
byte[] encryptedData,
byte[] optionalEntropy,
DataProtectionScope scope
)
Run Code Online (Sandbox Code Playgroud)
Linux上是否有等效的API? 奖励是它可以方便地与Java集成.
如果没有,我有什么选择?
我有一个“来自野外”的 SqlException 堆栈跟踪,其中包含以下消息:
SHUTDOWN is in progress.
Login failed for user 'USERNAME'.
A severe error occurred on the current command.
The results, if any, should be discarded.
Run Code Online (Sandbox Code Playgroud)
有谁知道这个错误的SqlError.Number属性是什么?我无法重现这种情况以通过调试来确定它。特别是,我想知道“正在关闭”的错误代码,而不是“严重错误...”的其他情况。