Java Code Examples for org.witness.proofmode.crypto.HashUtils

The following examples show how to use org.witness.proofmode.crypto.HashUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: proofmode   Source File: ShareProofActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
private boolean shareProof (Uri uriMedia, File fileMedia, ArrayList<Uri> shareUris, StringBuffer sb, PrintWriter fBatchProofOut, boolean shareMedia) throws FileNotFoundException {

        String hash = HashUtils.getSHA256FromFileContent(getContentResolver().openInputStream(uriMedia));

        if (hash != null) {
            File fileFolder = MediaWatcher.getHashStorageDir(hash);

            if (fileFolder == null)
                return false;

            File fileMediaSig = new File(fileFolder, hash + OPENPGP_FILE_TAG);
            File fileMediaProof = new File(fileFolder, hash + PROOF_FILE_TAG);
            File fileMediaProofSig = new File(fileFolder, hash + PROOF_FILE_TAG + OPENPGP_FILE_TAG);

            if (fileMediaSig.exists() && fileMediaProof.exists() && fileMediaProofSig.exists()) {
                generateProofOutput(fileMedia, new Date(fileMedia.lastModified()), fileMediaSig, fileMediaProof, fileMediaProofSig, hash, shareMedia, fBatchProofOut, shareUris, sb);
                return true;
            }
        }

        return false;

    }
 
Example 2
Source Project: proofmode   Source File: ShareProofActivity.java    License: GNU General Public License v3.0 5 votes vote down vote up
private boolean proofExists (Uri mediaUri) throws FileNotFoundException {
    boolean result = false;

    String hash = HashUtils.getSHA256FromFileContent(getContentResolver().openInputStream(mediaUri));

    if (hash != null) {

        File fileFolder = MediaWatcher.getHashStorageDir(hash);

        if (fileFolder != null ) {
            File fileMediaSig = new File(fileFolder, hash + OPENPGP_FILE_TAG);
            File fileMediaProof = new File(fileFolder, hash + PROOF_FILE_TAG);
            File fileMediaProofSig = new File(fileFolder, hash + PROOF_FILE_TAG + OPENPGP_FILE_TAG);

            if (fileMediaSig.exists() && fileMediaProof.exists() && fileMediaProofSig.exists()) {
                result = true;
            } else {
                //generate now?
                result = false;


            }
        }
    }

    return result;
}