DEV Community

hamidsafiullah
hamidsafiullah

Posted on

Trying to implement Facebook Conceal method for saving encrypted password but didn't work?

Trying to implement facebook conceal to save encrypted passwords, i removed all errors and android app runs but as i used insert method in Registration so when i click the registration button the app stops working. Before adding the crypto code the app was working fine and was saving passwords.

public boolean insert(String email, String password, String uName, String pNo){
SQLiteDatabase db =this.getWritableDatabase();
Crypto crypto = new Crypto(new SharedPrefsBackedKeyChain(this,CryptoConfig.KEY_256),
        new SystemNativeCryptoLibrary(), CryptoConfig.KEY_256);
byte[] cipherText =null;
try {
    cipherText = crypto.encrypt(password.getBytes(),entity);
} catch (KeyChainException e) {
    e.printStackTrace();
} catch (CryptoInitializationException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}
ContentValues contentValues = new ContentValues();
contentValues.put("Email", email);

String finalString = null;
try {
    finalString = new String(cipherText, "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
}
contentValues.put("Password", finalString);
contentValues.put("UserName", uName);
contentValues.put("PhoneNumber", pNo);
long ins =db.insert("userTable", null, contentValues);
if(ins==-1) return false;
else return true;
Enter fullscreen mode Exit fullscreen mode

}

Top comments (0)