1 /* 2 * Created on 08-Jun-2004 3 * Created by Paul Gardner 4 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 package org.gudy.azureus2.core3.util; 21 22 import java.security.*; 23 24 import org.gudy.bouncycastle.jce.provider.BouncyCastleProvider; 25 26 27 public class 28 MD4Hasher 29 { 30 protected MessageDigest md4; 31 32 /** 33 * Uses bouncy castle provider 34 * 35 */ 36 37 public MD4Hasher()38 MD4Hasher() 39 { 40 try{ 41 md4 = MessageDigest.getInstance("MD4", BouncyCastleProvider.PROVIDER_NAME ); 42 43 }catch( Throwable e ){ 44 45 // should never get here 46 47 Debug.printStackTrace( e ); 48 } 49 } 50 51 public void reset()52 reset() 53 { 54 md4.reset(); 55 } 56 57 public void update( byte[] data, int pos, int len )58 update( 59 byte[] data, 60 int pos, 61 int len ) 62 { 63 md4.update( data, pos, len ); 64 } 65 66 public void update( byte[] data )67 update( 68 byte[] data ) 69 { 70 update( data, 0, data.length ); 71 } 72 73 public byte[] getDigest()74 getDigest() 75 { 76 return( md4.digest()); 77 } 78 } 79