Giter VIP home page Giter VIP logo

rsaencryptor's Introduction

RSA

NSString *content = @"hello word";

// 私钥签名 公钥验签

NSString *signedString = [RSAEncryptor signString:content privateKey:private_key];

NSLog(@"签名:%@",signedString);

BOOL verify = [RSAEncryptor verifyString:content withSign:signedString publicKey:publick_key];

NSLog(@"验签:%@",verify?@"成功":@"失败");

// key公钥加密 key私钥解密

NSString *encryptString = [RSAEncryptor encryptString:content publicKey:publick_key];

NSLog(@"key加密:%@",encryptString);

NSString *decryptString = [RSAEncryptor decryptString:encryptString privateKey:private_key];

NSLog(@"key解密:%@",decryptString);

// .pem公钥加密 .pem私钥解密

NSString *publicPemPath = [[NSBundle mainBundle] pathForResource:@"rsa_public_key" ofType:@"pem"];

NSString *pemEncryptString = [RSAEncryptor encryptString:content publicKeyWithContentsOfPEMFile:publicPemPath];

NSLog(@"pem加密:%@",pemEncryptString);

NSString *privatePemPath = [[NSBundle mainBundle] pathForResource:@"rsa_private_key" ofType:@"pem"];

NSString *pemDecryptString = [RSAEncryptor decryptString:pemEncryptString privateKeyWithContentsOfPEMFile:privatePemPath];

NSLog(@"pem解密:%@",pemDecryptString);

// .der加密 .p12解密

NSString *derPath = [[NSBundle mainBundle] pathForResource:@"rsacert" ofType:@"der"];

NSString *derEncryptString = [RSAEncryptor encryptString:content publicKeyWithContentsOfFile:derPath];

NSLog(@"der加密:%@",derEncryptString);

NSString *pPath = [[NSBundle mainBundle] pathForResource:@"p" ofType:@"p12"];

NSString *p12Decrypt = [RSAEncryptor decryptString:derEncryptString privateKeyWithContentsOfFile:pPath password:@"123456"];

NSLog(@"p12解密:%@",p12Decrypt);

rsaencryptor's People

Contributors

superman-fly avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.