public static String sign(final Context context, final String data) throws GeneralSecurityException {
		final KeyStore keystore = getAndroidKeyStore();
		final KeyStore.Entry entry = keystore.getEntry(KEYPAIR_ALIAS, null);
		final PrivateKey private_key = (entry instanceof KeyStore.PrivateKeyEntry) ? ((KeyStore.PrivateKeyEntry) entry).getPrivateKey()
				: generateCertificate(context).getPrivate();
		final Signature signer = Signature.getInstance("SHA512withRSA");
		signer.initSign(private_key);
		signer.update(data.getBytes(ISO_8859_1));
		return new String(signer.sign(), ISO_8859_1);
	}
Utility for signing and verification with Android Keystore.

Created by Oasis on 2017/9/22.
engine/src/main/java/com/oasisfeng/island/util/Cryptography.java