Android Open Source - android-pkpass-viewer Sha1






From Project

Back to project page android-pkpass-viewer.

License

The source code is released under:

MIT License

If you think the Android project android-pkpass-viewer 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.manso.mytickets.utils;
/*from   w  ww .  jav a2s  .  co m*/
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Sha1 {
  public String fromFile(File file) throws IOException, NoSuchAlgorithmException {
    MessageDigest md = MessageDigest.getInstance("SHA1");
      FileInputStream fis = new FileInputStream(file);
      String out = null;
      try 
      {
        byte[] dataBytes = new byte[1024];
     
        int nread = 0; 
     
        while ((nread = fis.read(dataBytes)) != -1) {
          md.update(dataBytes, 0, nread);
        };
     
        byte[] mdbytes = md.digest();
     
        //convert the byte to hex format
        StringBuffer sb = new StringBuffer("");
        for (int i = 0; i < mdbytes.length; i++) {
          sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
        }
        out = sb.toString();        
      } finally {
        fis.close();        
      }        
      return out;        
  }
}




Java Source Code List

com.manso.mytickets.HandleIntentAsyncTask.java
com.manso.mytickets.TicketBackFragment.java
com.manso.mytickets.TicketFrontFragment.java
com.manso.mytickets.ViewTicketFrontActivity.java
com.manso.mytickets.services.EventTicketPassStrategy.java
com.manso.mytickets.services.IPassStrategy.java
com.manso.mytickets.services.ManifestService.java
com.manso.mytickets.services.PassReadingService.java
com.manso.mytickets.services.PassStorageService.java
com.manso.mytickets.services.PassStrategyService.java
com.manso.mytickets.services.PassTypes.java
com.manso.mytickets.utils.BarcodeEncoder.java
com.manso.mytickets.utils.FileReader.java
com.manso.mytickets.utils.ImageUtils.java
com.manso.mytickets.utils.RandomNameGenerator.java
com.manso.mytickets.utils.Sha1.java