hawk icon indicating copy to clipboard operation
hawk copied to clipboard

Hawk Decrypt failed

Open AlexTip opened this issue 8 years ago • 2 comments

Hello, I have trouble with getting value in this case:

  1. I use init in my Application file Hawk.init(applicationContext).build()

  2. When user logouts I deleteAll Hawk.deleteAll()

  3. And I delete all application files -

public static void clearApplicationData(Context context){
        File cache = context.getCacheDir();
        File appDir = new File(cache.getParent());
        if (appDir.exists()) {
            String[] children = appDir.list();
            for (String s : children) {
                if (!s.equals("lib")) {
                    deleteDir(new File(appDir, s));
                }
            }
        }
    }
  1. And when user log in again (current session) I put user data to Hawk Hawk.put(KEY_ID, id)

  2. When app restart method Hawk.get(KEY_ID) returns null And in log

E/Hawk: onLog: Hawk.get ->  Decrypt failed: The message could not be decrypted successfully.It has either been tampered with or the wrong resource is being decrypted.
E/Hawk: onLog: Hawk.get -> Decrypt failed

But Hawk.contains(KEY_ID) return true

But when after 3 step, restart app, all work fine......

In Your documentation to method deleteAll written

Clears the storage, note that crypto data won't be deleted such as salt key etc.
Use resetCrypto in order to deleteAll crypto information

But I don't find method resetCrypto()

Android version - any; Phone model - any; Version Hawk - 2.0.1;

Thanks.

AlexTip avatar Jan 21 '17 17:01 AlexTip

I'll take a look for this one. 👍

orhanobut avatar Apr 02 '18 08:04 orhanobut

After the app is updated

Decrypt failed: The message could not be decrypted successfully. It has either been tampered with or the wrong resource is being decrypted.

May be the reason for the java bean to add a new field?

erleizh avatar Nov 01 '18 06:11 erleizh