Android Open Source

 

Open Source Java App

RSA Crypto

In order to be able to decrypt the encoded text, we need to save and use the private key.

The private key can be converted to a string variable and saved to a file. The file can then be read into a string variable. But it will not be possible to recover the private key. No option to convert any data to RSA key format 

As they say, this is done for safety. So that you do not store the private key in files in an insecure area.

This statement can be disputed, but for practical application this dispute does not make sense.

To save and reuse the private key in your application, you need to use STORAGE. Android REPOSITORY.

It's the same as Windows.

It uses the utility  MCC

Android KeyStore API

Generate a key and save it in the KeyStore      

 final KeyGenerator keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
final KeyGenParameterSpec keyGenParameterSpec = new KeyGenParameterSpec.Builder("MyKeyAlias",
        KeyProperties.PURPOSE_ENCRYPT | KeyProperties.PURPOSE_DECRYPT)
        .setBlockModes(KeyProperties.BLOCK_MODE_GCM)
        .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
        //.setUserAuthenticationRequired(true) //requires lock screen, invalidated if lock screen is disabled
        //.setUserAuthenticationValidityDurationSeconds(120) //only available x seconds from password authentication. -1 requires finger print - every time
        .setRandomizedEncryptionRequired(true) //different ciphertext for same plaintext on each call
        .build();
keyGenerator.init(keyGenParameterSpec);
keyGenerator.generateKey();

 

As before, let's try to use it in a finished Java project

 

Open Source Java App

 https://www.linkedin.com/in/valery-shmelev-479206227/

 

Comments

Popular posts from this blog

Android Source Code

CryptoNOTE with AES

Android Photo Registrar OFLAMERON