Package penny.recmd5

Examples of penny.recmd5.MD5State


*/
public class Test {

    public static void main(String... args) {
        MessageDigest expected = null;
        MD5MessageDigest test = null;
        try {
            expected = MessageDigest.getInstance("md5");
            test = new MD5MessageDigest();
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
        }

        String message = "Hello world!";

        expected.update(message.getBytes());
        String s = new BigInteger(1, expected.digest()).toString(16);
        if (s.length() == 31) {
            s = "0" + s;
        }
        test.digest(message.getBytes());
        System.out.println(s);
        System.out.println(test.getState().toString());
    }
View Full Code Here


    private Download download;

    public MD5er(Download download) {
        this.download = download;
        md5Model = Model.getApplicationSettings().getMd5ingModel();
        md5 = new MD5MessageDigest(download.getMD5());
    }
View Full Code Here

    }

    public void resetMD5FromFile(File file) throws FileNotFoundException, IOException {
        if (Model.generateMD5(download)) {
            download.setMD5(new MD5State());
            md5 = new MD5MessageDigest(download.getMD5());

            InputStream in = null;
            try {
                in = new FileInputStream(file);
                byte[] buffer = new byte[10240];
View Full Code Here

        }
    }

    public void reset() {
        download.setMD5(new MD5State());
        md5 = new MD5MessageDigest(download.getMD5());
    }
View Full Code Here

    }

    public static MD5State getMD5State(File file) {
        InputStream in = null;
        try {
            MD5MessageDigest md5 = new MD5MessageDigest();
            in = new FileInputStream(file);
            byte[] buffer = new byte[10240];
            int read = in.read(buffer);
            while (read != -1) {
                md5.update(buffer, 0, read);
                read = in.read(buffer);
            }
            md5.digest();
            return md5.getState();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Util.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
View Full Code Here

        downloads.getReadWriteLock().readLock().unlock();
    }

    public void updateMD5(Download d) {
        if (Model.generateMD5(d)) {
            MD5State oldValue = md5ValuesMap.get(d);
            MD5State md5 = d.getMD5();
            boolean doUpdate = false;
            if (oldValue == null || !oldValue.equals(md5)) {
                doUpdate = true;
            }
            if (doUpdate) {
                if (oldValue == null) {
                    oldValue = new MD5State();
                }
                oldValue.copy(md5);
                dao.updateDownload(d, Download.PROP_MD5);
            }
        }
View Full Code Here

        this.id = id;
        hrefLinks = GlazedLists.threadSafeList(new BasicEventList<String>());
        srcLinks = GlazedLists.threadSafeList(new BasicEventList<String>());
        words = GlazedLists.threadSafeList(new BasicEventList<String>());
        locations = GlazedLists.threadSafeList(new BasicEventList<String>());
        md5 = new MD5State();
        linkState = new LinkState();
        wordBuffer = "";
        savePath = "";
        tempPath = "";
        extraProps = new HashMap<String, Object>();
View Full Code Here

    /**
     * @param MD5 the MD5 to set
     */
    public void setMD5(MD5State md5) {
        MD5State oldValue = this.md5;
        this.md5 = md5;
        propertySupport.firePropertyChange(PROP_MD5, oldValue, this.md5);
    }
View Full Code Here

        md5 = new MD5MessageDigest(download.getMD5());
    }

    public void resetMD5FromFile(File file) throws FileNotFoundException, IOException {
        if (Model.generateMD5(download)) {
            download.setMD5(new MD5State());
            md5 = new MD5MessageDigest(download.getMD5());

            InputStream in = null;
            try {
                in = new FileInputStream(file);
View Full Code Here

            }
        }
    }

    public void reset() {
        download.setMD5(new MD5State());
        md5 = new MD5MessageDigest(download.getMD5());
    }
View Full Code Here

TOP

Related Classes of penny.recmd5.MD5State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.