Create a key pair
Enter the following script one at a time in the terminal
OpenSSL Genrsa- outPrivate_key. PEM 1024x768OpenSSL Req-new-key Private_key. PEM- outRsacertreq. CSROpenSSL x509-req-days3650-inchRsacertreq. CSR-signkey Private_key. PEM- outRsacert. CRTOpenSSL X509-outform der-inchRsacert. CRT- outPublic_key. DerCreate Public_key. DerFor Iosopenssl Pkcs12-export- outPrivate_key. P12-inkey Private_key. PEM-inchRsacert. CRTCreate Private_key. PFor IOS. This step, please remember the password you entered, iOS code will use the OpenSSL RSA-inchPrivate_key. PEM- outRsa_public_key. PEM-pubout//Create Rsa_public_key. PEMFor Javaopenssl Pkcs8-topk8-inchPrivate_key. PEM- outPkcs8_private_key. PEM-nocrypt//Create Pkcs8_private_key. PEMFor Java
The above seven steps generate a total of 7 files. where Public_key.der and private_key.p12 the public key is for iOS, RSA_PUBLIC_KEY.PEM and Pkcs8_private_key.pem are for Java.
Generate Encrypted files
Install Qmrsa.app under Mac System
Encryption
- Open Rsa_public_key.pem and PKCS8_PRIVATE_KEY.PEM get the data inside (remove the tail, line, and space), respectively, into the private key string, the public key string. So we can encrypt and decrypt.
- Import unencrypted original files,
- On demand is to be able to import directly in the background
Decrypt
As above, first fill in the key pair. To require import, export
Encryption and decryption of data by RSA for Mac system