package com.qmth.qrzk.repository.utils;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

public class DESCoder {

	private static byte[] Key = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
//	private static byte[] IV = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
	
	public static byte[] desDecrypt(byte[] bytes) throws Exception {
		Cipher cipher = Cipher.getInstance("DES/ECB/NoPadding");
		DESKeySpec desKeySpec = new DESKeySpec(Key);

		SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
		SecretKey secretKey = keyFactory.generateSecret(desKeySpec);
		// IvParameterSpec iv = new IvParameterSpec(IV);
		cipher.init(Cipher.DECRYPT_MODE, secretKey);

		byte[] output = cipher.doFinal(bytes);
		return output;
	}
}
