private static String tryHashStringSha256(Context context,String input){
  String salt=createSalt(context);
  try {
    MessageDigest hash=MessageDigest.getInstance("SHA-256");
    hash.reset();
    hash.update(input.getBytes());
    hash.update(salt.getBytes());
    byte[] hashedBytes=hash.digest();
    return bytesToHex(hashedBytes);
  }
 catch (  NoSuchAlgorithmException e) {
    return input;
  }
}

private static String tryHashStringSha256 ( Context context , String input ) { String salt = createSalt ( context ) ; try { MessageDigest hash = MessageDigest . getInstance ( "SHA-256" ) ; hash . reset ( ) ; hash . update ( input . getBytes ( ) ) ; hash . update ( salt . getBytes ( ) ) ; byte [ ] hashedBytes = hash . digest ( ) ; return bytesToHex ( hashedBytes ) ; } catch ( NoSuchAlgorithmException e ) { return input ; } }
get a sha - 256 hash of the input string if the algorithm is available . if the algorithm is unavailable , return empty string .
