public class

Crypto

extends Object
java.lang.Object
   ↳ com.kinvey.android.secure.Crypto

Class Overview

This class offers publicly accessible methods for handling on-device encryption of arbitrary strings.

It assumes Keys are stored locally, which are managed by the version dependant KeyStore

This class applies the PRNG fixes recommended by Google to handle possible low entropy in /dev/urandom

Summary

Public Constructors
Crypto()
Public Methods
final static String decrypt(String data)
Public wrapper method to decrypt a string, will load key
static InputStream decryptInputStream(CipherInputStream stream)
static OutputStream decryptOutputStream(CipherOutputStream stream)
static void deleteKeys()
final static String encrypt(String text)
Public wrapper method to encrypt a string
static CipherInputStream encryptInputStream(InputStream stream)
static CipherOutputStream encryptOutputStream(OutputStream stream)
static String toHex(byte[] stringBytes)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Crypto ()

Public Methods

public static final String decrypt (String data)

Public wrapper method to decrypt a string, will load key

Parameters
data the encrypted string to decrypt
Returns
  • a decrypted version of the string
Throws
Exception

public static InputStream decryptInputStream (CipherInputStream stream)

Throws
Exception

public static OutputStream decryptOutputStream (CipherOutputStream stream)

Throws
Exception

public static void deleteKeys ()

public static final String encrypt (String text)

Public wrapper method to encrypt a string

Parameters
text the string to encrypt
Returns
  • the encrypted string
Throws
Exception

public static CipherInputStream encryptInputStream (InputStream stream)

Throws
Exception

public static CipherOutputStream encryptOutputStream (OutputStream stream)

Throws
Exception

public static String toHex (byte[] stringBytes)