android-rsa

项目地址:haodynasty/android-rsa
简介:RSA 加密库,支持自动生成公私钥,字符加密,大文本文件加密,一键集成
更多:作者   提 Bug   
标签:
rsa-encryption-decryption-rsa-android-rsa-

rsa encryption and decryption by android

License Download

Import

add to build.gradle,${latest.version} is Download

dependencies {
    compile 'com.blakequ.rsa:rsa:${latest.version}'
}

maven

<dependency>
  <groupId>com.blakequ.rsa</groupId>
  <artifactId>rsa</artifactId>
  <version>${latest.version}</version>
  <type>pom</type>
</dependency>

How to use

you can download example and study how to use

For server code, you can find in example:com/blakequ/rsademo/javalib

1. set key

FileEncryptionManager mFileEncryptionManager = FileEncryptionManager.getInstance();
//1.you can use generate public and private key
mFileEncryptionManager.generateKey();
//you can invoke getPublickey() and getPrivateKey() to save key to local file

//or 2.set public key and private key by youself(not use auto generate key)
mFileEncryptionManager.setRSAKey(String publicKey, String privateKey);
mFileEncryptionManager.setRSAKey(RSAPublicKey publicKey, RSAPrivateKey privateKey)

2. encrypt file or data

byte[] data = FileUtils.getBytesFromInputStream(getResources().getAssets().open("*.txt"));
//from byte array
byte[] result = mFileEncryptionManager.encryptFileByPublicKey(data, saveEncryFile);
//or from file
byte[] result = mFileEncryptionManager.encryptFileByPublicKey(ogirialFile, saveEncryFile);

3. decrypt file or data

byte[] result = mFileEncryptionManager.decryptFileByPrivateKey(encryFile, decryFile);
byte[] result = mFileEncryptionManager.decryptFileByPrivateKey(encryByteData, decryFile);

link

Android 开发经验分享
Android 开发经验分享