Pastebin

Paste #199:

< previous paste - next paste>

Pasted by encode

Download View as text

package utils;

import java.security.*;

import java.math.*;



public class Encode {



	/**

	 * @param args

	 */

	public String encode(byte[] encString, int key) {



		 try {

	            MessageDigest md5 = MessageDigest.getInstance("MD5");

	            md5.update(encString);

	            byte[] testDigest = md5.digest();

	            BigInteger big = new BigInteger(1, testDigest);

	            BigInteger big_encoded = big.subtract(BigInteger.valueOf(key));

	            String hex_encoded = big_encoded.toString(16);

	            

	            //Hvis vaerdien kun er 31 tal, skal der et 0 foran.

	            if(hex_encoded.length() == 31){

	            	return 0+hex_encoded;

	            }else{

	            	return hex_encoded;

	            }

	        } catch (NoSuchAlgorithmException e) {

	        	return null;

	        }

	        



	}



}

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.