Android Open Source - android-child-lock Utils






From Project

Back to project page android-child-lock.

License

The source code is released under:

Apache License

If you think the Android project android-child-lock listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.alimuzaffar.android.childlock.utils;
// w  ww.  ja  v a 2  s  .  com
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.MessageDigest;

public class Utils {
  // convert InputStream to String
  public static String getStringFromInputStream(InputStream is) {

    BufferedReader br = null;
    StringBuilder sb = new StringBuilder();

    String line;
    try {

      br = new BufferedReader(new InputStreamReader(is));
      while ((line = br.readLine()) != null) {
        sb.append(line);
      }

    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (br != null) {
        try {
          br.close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }

    return sb.toString();

  }

  public static String sha256(String base) {
    try {
      MessageDigest digest = MessageDigest.getInstance("SHA-256");
      byte[] hash = digest.digest(base.getBytes("UTF-8"));
      StringBuffer hexString = new StringBuffer();

      for (int i = 0; i < hash.length; i++) {
        String hex = Integer.toHexString(0xff & hash[i]);
        if (hex.length() == 1)
          hexString.append('0');
        hexString.append(hex);
      }

      return hexString.toString();
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
}




Java Source Code List

com.alimuzaffar.android.childlock.Constants.java
com.alimuzaffar.android.childlock.activities.LockScreenActivity.java
com.alimuzaffar.android.childlock.activities.ParentalControlActivity.java
com.alimuzaffar.android.childlock.adapters.EfficientAdapter.java
com.alimuzaffar.android.childlock.fragments.ListOfApplicationsFragment.java
com.alimuzaffar.android.childlock.fragments.ListOfLockedApplicationsFragment.java
com.alimuzaffar.android.childlock.fragments.SetPinDialogFragment.java
com.alimuzaffar.android.childlock.services.HeartBeat.java
com.alimuzaffar.android.childlock.utils.AppPrefs.java
com.alimuzaffar.android.childlock.utils.AppSettings.java
com.alimuzaffar.android.childlock.utils.Utils.java
model.AccessGranted.java