Suitable for android of the RSA tool.
- Initialize the PublicKey or PrivateKey method.
- Encrypt and decrypt rsa data.
- Compatible with openSSL.
- Compatible with android 2.3+.
InputStream inputStream = getBaseContext().getResources().openRawResource(R.raw.publickey);
String string = convertStreamToString(inputStream);
mPublicKey = RSAAndroid.openSSLPemStringToPublicKey(string);
Log.i(TAG, "public key init done");
...
byte[] result = RSAAndroid.encode(raw.getBytes(), mPublicKey);
Log.i(TAG, "encode data done");
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.itvincent-git:RSA-android:1.0.1'
}