一个高性能的白盒密码学 (WBC) 框架,旨在以一种防止攻击者提取或逆向工程密码密钥和操作的方式来保护它们,即使代码和内存完全暴露。 该框架以一种抵抗各种旁路攻击和逆向工程攻击的方式实现密码算法。
要使用 Swift Package Manager 将白盒密码学框架集成到您的 Xcode 项目中,请按照以下步骤操作
https://github.com/DrDijkstra/WhiteboxCryptography
。Podfile
pod 'WhiteboxCryptography', '~> 1.0'
在终端中运行 pod install
。
在 Xcode 中打开 .xcworkspace
文件。
要将白盒密码学与 Carthage 集成,请将以下内容添加到您的 Cartfile
github "DrDijkstra/WhiteboxCryptography"
然后运行 carthage update
以构建框架。
要在您的项目中使用白盒密码学框架,请根据您的软件包管理器按照相应的说明进行操作
只需将框架导入到您的 Swift 文件中
import WhiteboxCryptography
WhiteboxCryptography
和 WhiteboxCryptographySDK
的大小写,因为某些环境可能区分大小写。// Example of how to use the encryption and decryption functionalities
import Foundation
import WhiteboxCryptography
// Initialize the WhiteboxCryptographySDK with a memory key
let memoryKey = "your-memory-key".data(using: .utf8)!
let whiteboxSDK = WhiteboxCryptographySDK(memoryKey: memoryKey)
// Sample data to encrypt
let data = "Sensitive data".data(using: .utf8)!
// Define a cryptographic key and IV
let encryptionKey = "your-encryption-key".data(using: .utf8)!
let iv = "your-iv-string".data(using: .utf8) // Optional IV for block ciphers
let algorithm: CryptoAlgorithm = .aes(keySize: 256, mode: .ecb, processingType: .regular) // Replace with the actual algorithm
// Encrypt the data
do {
if let encryptedData = try whiteboxSDK.encrypt(data: data, withKey: encryptionKey, iv: iv, algorithm: algorithm) {
print("Encrypted Data: \(encryptedData.base64EncodedString())")
// Decrypt the data
if let decryptedData = try whiteboxSDK.decrypt(data: encryptedData, withKey: encryptionKey, iv: iv, algorithm: algorithm) {
let decryptedString = String(data: decryptedData, encoding: .utf8)
print("Decrypted String: \(decryptedString ?? "Failed to decrypt")")
} else {
print("Decryption failed")
}
} else {
print("Encryption failed")
}
}catch(let error){
}
}
此实现中提供以下密码算法
AES(高级加密标准):一种用于保护数据的对称密钥加密标准。
AESKeySize
) 和操作模式 (AESMode
)。DES(数据加密标准):一种对称密钥分组密码,以前是一种广泛使用的数据加密方法。
Triple DES (3DES):DES 的增强版本,将 DES 算法应用于每个数据块三次。
CAST:一系列为强加密设计的对称密钥分组密码。
RC2 (Ron's Code 2):一种用于硬件或软件环境的分组密码,通常用于文件加密。
该框架以白盒密码学方式支持这些算法的加密、解密和哈希。
本框架基于 MIT 许可证获得许可。 有关更多详细信息,请参见 LICENSE 文件。
我们欢迎您为改进框架做出贡献! 要贡献
git checkout -b feature-branch
)。git commit -am 'Add new feature'
)。git push origin feature-branch
)。如有问题或需要支持,请通过以下方式联系我们
电子邮件:deysanjay121@gmail.com
GitHub:https://github.com/DrDijkstra/WhiteboxCryptography