Latest 0.0.5
Homepage https://github.com/NianJi/BBRSACryptor
License MIT
Platforms ios 6.0, requires ARC
Dependencies OpenSSL
Frameworks Foundation
Authors

使用OpenSSL进行公钥和私钥的加解密

以及私钥签名,公钥验签

添加到你的工程

pod 'BBRSACryptor'

如何加载密钥

从文件中读取密钥:

BBRSACryptor *cryptor = [[BBRSACryptor alloc] init];
NSData *keyData = [NSData dataWithContentsOfFile:keyPath];
[cryptor importRSAPublicKeyPEMData:keyData];

使用byte数组方式读入:

获取byte数组:

./rsatool read public.pem   # rsatool 是Demo工程中的另一个target: rsatool 编译出的小工具

在代码中读取字节数组:

char keyBytes[] = {45,45,45,45,45,66,69,71,73,78,32,80,85,66,76,73,67,32,75,69,89,45,45,45,45,45,10,77,73,73,66,73,106,65,78,66,103,107,113,104,107,105,71,57,119,48,66,65,81,69,70,65,65,79,67,65,81,56,65,77,73,73,66,67,103,75,67,65,81,69,65,49,71,83,49,72,103,51,69,53,105,55,113,114,75,115,69,114,81,70,116,10,90,49,110,,49,118,80,84,85,101,79,113,107,117,74,110,99,105,115,86,53,121,101,89,104,75,10,83,83,66,107,67,114,65,88,114,105,52,81,76,110,121,85,57,87,73,57,80,70,115,76,89,119,109,82,121,109,102,102,104,121,73,57,97,108,106,107,77,108,55,112,122,82,115,105,117,51,72,117,50,52,47,68,79,97,99,78,103,80,83,121,10,115,119,73,68,65,81,65,66,10,45,45,45,45,45,69,78,68,32,80,85,66,76,73,67,32,75,69,89,45,45,45,45,45,10};
NSData *pemData = [NSData dataWithBytes:keyBytes length:sizeof(keyBytes)];
[rsaCryptor importRSAPublicKeyPEMData:pemData];

Latest podspec

{
    "name": "BBRSACryptor",
    "version": "0.0.5",
    "summary": "RSA cryptor.",
    "description": "u4f7fu7528OpenSSLu7684Apiu8fdbu884cRSAu7684u52a0u5bc6u548cu89e3u5bc6uff0cu652fu6301u516cu94a5u52a0u5bc6uff0cu79c1u94a5u89e3u5bc6uff1bu79c1u94a5u52a0u5bc6uff0cu516cu94a5u89e3u5bc6.",
    "homepage": "https://github.com/NianJi/BBRSACryptor",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "liukun": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/NianJi/BBRSACryptor.git",
        "tag": "0.0.5"
    },
    "source_files": [
        "BBRSACryptor",
        "BBRSACryptor/**/*.{h,m}"
    ],
    "frameworks": "Foundation",
    "dependencies": {
        "OpenSSL": []
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This