You can use JNCryptor (a third-party library) to encrypt/decrypt Strings. I'm not sure yet on images, although there may be a way to first convert an image to a String, in which case you could then encrypt it as usual.
In iOS, it's called "RNCryptor" (they work together fine I believe). For example, this is what I do in Swift (I haven't done it in Android Java yet, although it should look pretty similar I think):
import UIKit
import RNCryptor
private let encryptKey = "32-chars-alpha-numeric-pass".data(using: .utf8)
private let hmacKey = "Some-other-32-chars-alpha-numeric-pass".data(using: .utf8)
extension String {
func encryptIt() -> String {
let data = self.data(using: .utf8)
let encryptor = RNCryptor.EncryptorV3(encryptionKey: encryptKey!, hmacKey: hmacKey!)
let ciphertext = encryptor.encrypt(data: data!)
return ciphertext.base64EncodedString(options: NSData.Base64EncodingOptions.endLineWithCarriageReturn)
}
func decryptIt() -> String {
do {
let data = Data.init(base64Encoded: self)
let decryptor = RNCryptor.DecryptorV3(encryptionKey: encryptKey!, hmacKey: hmacKey!)
let originalData = try decryptor.decrypt(data: data!)
let base64EncodedData = originalData.base64EncodedData()
let newData = NSData(base64Encoded: base64EncodedData, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters)!
let newNSString = NSString(data: newData as Data, encoding: String.Encoding.utf8.rawValue)!
return newNSString as String
} catch {
print(error)
return ""
}
}
}