All pastes #1804883 Raw Edit

is not working

public java v1 · immutable
#1804883 ·published 2010-02-21 18:48 UTC
rendered paste body
package a;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;import java.security.NoSuchProviderException;import java.security.Security;import org.bouncycastle.jce.provider.BouncyCastleProvider;import org.bouncycastle.jce.provider.JDKMessageDigest;public class GOSTer {	private MessageDigest gost3411;	private GOSTer(){		Security.addProvider(new BouncyCastleProvider());		try {			gost3411 = JDKMessageDigest.GOST3411.getInstance("GOST3411", "BC");		} catch (NoSuchAlgorithmException e) {			// TODO Auto-generated catch block			e.printStackTrace();		} catch (NoSuchProviderException e) {			// TODO Auto-generated catch block			e.printStackTrace();		}	}		private String convertToUpperCaseHex(byte[] data) {        StringBuffer buf = new StringBuffer();        for (int i = 0; i < data.length; i++) {            int halfbyte = (data[i] >>> 4) & 0x0F;            int two_halfs = 0;            do {                if ((0 <= halfbyte) && (halfbyte <= 9))                    buf.append((char) ('0' + halfbyte));                else                    buf.append((char) ('a' + (halfbyte - 10)));                halfbyte = data[i] & 0x0F;            } while(two_halfs++ < 1);        }        return buf.toString().toUpperCase();    }	public static void main(String argv[]){		GOSTer hasher=new GOSTer();		String[] elements={"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};		int[] indices={0,-1,-1,-1,-1};		char[] followingChars=new char[10];		int step=0;		while(true){			for(int i=0;i<indices.length;i++)				if(indices[i]>=elements.length){					indices[i]=0;					if(i+1>indices.length){						System.out.println("finished!");						return;					}					indices[i+1]++;				}			int n=0;			for(int i=0;i<indices.length;i++){				if(indices[i]>-1){					n++;					followingChars[i]=elements[indices[i]].charAt(0);				}else{					break;				}			}			indices[0]++;			String strToHash=new String(followingChars,0,n)+"pryL";			String hash=hasher.convertToUpperCaseHex(hasher.gost3411.digest(strToHash.getBytes()));			if(hash.equals("16CC9F1FF65688E040F5ADA82A41A258FF948769CDA4C4A17D85228A6F358971")){				System.out.println("GOST3411(\"" + strToHash + "\")\t" + hash);				return;			}			if((step++)%1e5==0)				System.out.println("> "+step+" "+n+" "+strToHash+" "+hash);		}	}}