Android SharedPreferences Get getSaltFromPreferences(SharedPreferences prefs)

Here you can find the source of getSaltFromPreferences(SharedPreferences prefs)

Description

get Salt From Preferences

Declaration

private static byte[] getSaltFromPreferences(SharedPreferences prefs) 

Method Source Code

//package com.java2s;

import android.content.SharedPreferences;
import android.util.Base64;

public class Main {
    private static final String KEY_PR_SALT = "com.venmo.pin.pr_salt";

    private static byte[] getSaltFromPreferences(SharedPreferences prefs) {
        return decode(getStringFromPrefsOrThow(prefs, KEY_PR_SALT));
    }/*from  w w  w . j  ava 2s  .com*/

    private static byte[] decode(String src) {
        return Base64.decode(src, Base64.DEFAULT);
    }

    private static String getStringFromPrefsOrThow(SharedPreferences prefs,
            String key) {
        String val = prefs.getString(key, null);
        if (val == null) {
            throw new NullPointerException(
                    "Trying to retrieve pin value before it's been set");
        }
        return val;
    }
}

Related

  1. getPrefObject(SharedPreferences pref, String key)
  2. getPrefObject(SharedPreferences pref, String key)
  3. getPrefBoolean(Context c, String key, boolean defValue)
  4. getPrefInt(Context c, String key, int defValue)
  5. getPrefString(Context c, String key, String defValue)
  6. getPinHashFromPreferences(SharedPreferences prefs)
  7. isRegistrationExpired(SharedPreferences prefs)
  8. asyncCommit( final SharedPreferences.Editor editor)