public static byte[] patternToHash(List<LockPatternView.Cell> pattern){
  if (pattern == null) {
    return null;
  }
 else {
    int size=pattern.size();
    byte[] res=new byte[size];
    for (int i=0; i < size; i++) {
      LockPatternView.Cell cell=pattern.get(i);
      res[i]=(byte)cell.getIndex();
    }
    MessageDigest md=null;
    try {
      md=MessageDigest.getInstance("SHA-1");
      return md.digest(res);
    }
 catch (    NoSuchAlgorithmException e) {
      e.printStackTrace();
      return res;
    }
  }
}

public static byte [ ] patternToHash ( List < LockPatternView . Cell > pattern ) { if ( pattern == null ) { return null ; } else { int size = pattern . size ( ) ; byte [ ] res = new byte [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { LockPatternView . Cell cell = pattern . get ( i ) ; res [ i ] = ( byte ) cell . getIndex ( ) ; } MessageDigest md = null ; try { md = MessageDigest . getInstance ( "SHA-1" ) ; return md . digest ( res ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; return res ; } } }
generate an sha - 1 hash for the pattern . not the most secure , but it is at least a second level of protection . first level is that the file is in a location only readable by the system process .
