{ "title": "加密算法示例", "description": "本示例展示了如何在iOS应用中使用SHA-256、AES和RSA进行数据加密。", "algorithms": [ { "name": "SHA-256", "description": "用于生成数据的哈希值,确保数据的完整性和一致性。", "method": "CCCryptorHash", "example": "CCCryptorStatus hashStatus = CCCryptorHash(kCCEncrypt, kCCAlgorithmSHA256, 0x0000, NULL, 0, (const void *)data.bytes, data.length, hashBuffer, sizeof(hashBuffer), &numBytesComputed);" }, { "name": "AES", "description": "用于对称加密和解密数据,确保数据的安全性。", "methods": [ { "name": "AES128Encrypt", "example": "NSData *encryptedData = [Tool encryptData:data key:key iv:iv];" }, { "name": "AES128Decrypt", "example": "NSData *decryptedData = [Tool decryptData:encryptedData key:key iv:iv];" } ] }, { "name": "RSA", "description": "用于非对称加密和解密数据,确保数据的安全性和私有性。", "methods": [ { "name": "RSAGenerateKeyPair", "example": "[Tool generateRSAKeyPair];" }, { "name": "RSAEncrypt", "example": "NSData *encryptedData = [Tool encryptData:data publicKey:publicKey];" }, { "name": "RSADecrypt", "example": "NSData *decryptedData = [Tool decryptData:encryptedData privateKey:privateKey];" } ] } ], "usage": "这些算法通常封装在一个工具类中,直接调用相应的加密和解密方法即可。在使用时,请确保替换相关的密钥和数据。" }