private static Key toKey(byte[] key, String algorithm)
			throws InvalidKeyException, NoSuchAlgorithmException,
			InvalidKeySpecException {
		DESKeySpec spec = new DESKeySpec(key);
		SecretKey secretKey = new SecretKeySpec(key, algorithm);

		if (algorithm.equals(DES)) {
			SecretKeyFactory factory = SecretKeyFactory.getInstance(DES);
			secretKey = factory.generateSecret(spec);
		}
		return secretKey;
	}