Android SharedPreferences Get getPinHashFromPreferences(SharedPreferences prefs)

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

Description

get Pin Hash From Preferences

Declaration

private static byte[] getPinHashFromPreferences(SharedPreferences prefs) 

Method Source Code

//package com.java2s;

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

public class Main {
    private static final String KEY_PINPUT_PIN_HASH = "com.venmo.pin.pinputview_pin";

    private static byte[] getPinHashFromPreferences(SharedPreferences prefs) {
        return decode(getStringFromPrefsOrThow(prefs, KEY_PINPUT_PIN_HASH));
    }//from w ww  .  j a  v  a 2  s. c  om

    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. getPrefBoolean(Context c, String key, boolean defValue)
  3. getPrefInt(Context c, String key, int defValue)
  4. getPrefString(Context c, String key, String defValue)
  5. getSaltFromPreferences(SharedPreferences prefs)
  6. isRegistrationExpired(SharedPreferences prefs)
  7. asyncCommit( final SharedPreferences.Editor editor)