// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/data/FingerprintDecryptionResult.java
// public class FingerprintDecryptionResult extends FingerprintAuthenticationResult {
// 
//     private final char[] decrypted;
// 
//     /**
//      * Default constructor
//      *
//      * @param result    result of the fingerprint authentication
//      * @param message   message to be displayed to the user
//      * @param decrypted decrypted data
//      */
//     public FingerprintDecryptionResult(FingerprintResult result, String message, char[] decrypted) {
//         super(result, message);
//         this.decrypted = decrypted;
//     }
// 
//     /**
//      * @return decrypted data as a String. Can only be accessed if the result of the fingerprint
//      * authentication was of type {@link FingerprintResult#AUTHENTICATED}.
//      */
//     public String getDecrypted() {
//         return new String(getDecryptedChars());
//     }
// 
//     /**
//      * @return decrypted data as a char[]. Can only be accessed if the result of the fingerprint
//      * authentication was of type {@link FingerprintResult#AUTHENTICATED}.
//      */
//     public char[] getDecryptedChars() {
//         if (!isSuccess()) {
//             throw new IllegalAccessError("Fingerprint authentication was not successful, cannot access decryption result");
//         }
//         return decrypted;
//     }
// }
// 
// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/data/FingerprintEncryptionResult.java
// public class FingerprintEncryptionResult extends FingerprintAuthenticationResult {
// 
//     private final String encrypted;
// 
//     /**
//      * Default constructor
//      *
//      * @param result    result of the operation
//      * @param message   message to be displayed to the user
//      * @param encrypted encrypted data
//      */
//     public FingerprintEncryptionResult(FingerprintResult result, String message, String encrypted) {
//         super(result, message);
//         this.encrypted = encrypted;
//     }
// 
//     /**
//      * @return encrypted data, can only be accessed if the result was of
//      * type {@link FingerprintResult#AUTHENTICATED}
//      */
//     public String getEncrypted() {
//         if (!isSuccess()) {
//             throw new IllegalAccessError("Fingerprint authentication was not successful, cannot access encryption result");
//         }
//         return encrypted;
//     }
// }
// 
// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/data/FingerprintResult.java
// public enum FingerprintResult {
//     FAILED, HELP, AUTHENTICATED
// }


import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
import android.hardware.fingerprint.FingerprintManager.CryptoObject;
import android.support.annotation.Nullable;
import com.mtramin.rxfingerprint.data.FingerprintDecryptionResult;
import com.mtramin.rxfingerprint.data.FingerprintEncryptionResult;
import com.mtramin.rxfingerprint.data.FingerprintResult;
import javax.crypto.Cipher;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
			Cipher cipher = cipherProvider.getCipherForDecryption();
			return new CryptoObject(cipher);
		} catch (Exception e) {
			subscriber.onError(e);
			return null;
		}
	}

	@Override
	protected void onAuthenticationSucceeded(ObservableEmitter<FingerprintDecryptionResult> emitter, AuthenticationResult result) {
		try {
			Cipher cipher = result.getCryptoObject().getCipher();
			byte[] bytes = cipher.doFinal(encodingProvider.decode(encryptedString));

			emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.AUTHENTICATED, null, ConversionUtils.toChars(bytes)));
			emitter.onComplete();
		} catch (Exception e) {
			Logger.error("Unable to decrypt given value. RxFingerprint is only able to decrypt values previously encrypted by RxFingerprint with the same encryption mode.", e);
			emitter.onError(cipherProvider.mapCipherFinalOperationException(e));
		}

	}

	@Override
	protected void onAuthenticationHelp(ObservableEmitter<FingerprintDecryptionResult> emitter, int helpMessageId, String helpString) {
		emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.HELP, helpString, null));
	}

	@Override
	protected void onAuthenticationFailed(ObservableEmitter<FingerprintDecryptionResult> emitter) {
// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/data/FingerprintDecryptionResult.java
// public class FingerprintDecryptionResult extends FingerprintAuthenticationResult {
// 
//     private final char[] decrypted;
// 
//     /**
//      * Default constructor
//      *
//      * @param result    result of the fingerprint authentication
//      * @param message   message to be displayed to the user
//      * @param decrypted decrypted data
//      */
//     public FingerprintDecryptionResult(FingerprintResult result, String message, char[] decrypted) {
//         super(result, message);
//         this.decrypted = decrypted;
//     }
// 
//     /**
//      * @return decrypted data as a String. Can only be accessed if the result of the fingerprint
//      * authentication was of type {@link FingerprintResult#AUTHENTICATED}.
//      */
//     public String getDecrypted() {
//         return new String(getDecryptedChars());
//     }
// 
//     /**
//      * @return decrypted data as a char[]. Can only be accessed if the result of the fingerprint
//      * authentication was of type {@link FingerprintResult#AUTHENTICATED}.
//      */
//     public char[] getDecryptedChars() {
//         if (!isSuccess()) {
//             throw new IllegalAccessError("Fingerprint authentication was not successful, cannot access decryption result");
//         }
//         return decrypted;
//     }
// }
// 
// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/data/FingerprintEncryptionResult.java
// public class FingerprintEncryptionResult extends FingerprintAuthenticationResult {
// 
//     private final String encrypted;
// 
//     /**
//      * Default constructor
//      *
//      * @param result    result of the operation
//      * @param message   message to be displayed to the user
//      * @param encrypted encrypted data
//      */
//     public FingerprintEncryptionResult(FingerprintResult result, String message, String encrypted) {
//         super(result, message);
//         this.encrypted = encrypted;
//     }
// 
//     /**
//      * @return encrypted data, can only be accessed if the result was of
//      * type {@link FingerprintResult#AUTHENTICATED}
//      */
//     public String getEncrypted() {
//         if (!isSuccess()) {
//             throw new IllegalAccessError("Fingerprint authentication was not successful, cannot access encryption result");
//         }
//         return encrypted;
//     }
// }
// 
// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/data/FingerprintResult.java
// public enum FingerprintResult {
//     FAILED, HELP, AUTHENTICATED
// }


// Path: rxfingerprint/src/main/java/com/mtramin/rxfingerprint/RsaDecryptionObservable.java
import android.annotation.SuppressLint;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager.AuthenticationResult;
import android.hardware.fingerprint.FingerprintManager.CryptoObject;
import android.support.annotation.Nullable;
import com.mtramin.rxfingerprint.data.FingerprintDecryptionResult;
import com.mtramin.rxfingerprint.data.FingerprintEncryptionResult;
import com.mtramin.rxfingerprint.data.FingerprintResult;
import javax.crypto.Cipher;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;

			Cipher cipher = cipherProvider.getCipherForDecryption();
			return new CryptoObject(cipher);
		} catch (Exception e) {
			subscriber.onError(e);
			return null;
		}
	}

	@Override
	protected void onAuthenticationSucceeded(ObservableEmitter<FingerprintDecryptionResult> emitter, AuthenticationResult result) {
		try {
			Cipher cipher = result.getCryptoObject().getCipher();
			byte[] bytes = cipher.doFinal(encodingProvider.decode(encryptedString));

			emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.AUTHENTICATED, null, ConversionUtils.toChars(bytes)));
			emitter.onComplete();
		} catch (Exception e) {
			Logger.error("Unable to decrypt given value. RxFingerprint is only able to decrypt values previously encrypted by RxFingerprint with the same encryption mode.", e);
			emitter.onError(cipherProvider.mapCipherFinalOperationException(e));
		}

	}

	@Override
	protected void onAuthenticationHelp(ObservableEmitter<FingerprintDecryptionResult> emitter, int helpMessageId, String helpString) {
		emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.HELP, helpString, null));
	}

	@Override
	protected void onAuthenticationFailed(ObservableEmitter<FingerprintDecryptionResult> emitter) {
		emitter.onNext(new FingerprintDecryptionResult(FingerprintResult.FAILED, null, null));