根据密匙进行DES加密

@param key
密匙
@param info
要加密的信息
@return String 加密后的信息
552197
public static String encryptToDES(SecretKey key, String info) {
		// 定义 加密算法,可用 DES,DESede,Blowfish
		String Algorithm = "DES";
		// 加密随机数生成器 (RNG),(可以不写)
		SecureRandom sr = new SecureRandom();
		// 定义要生成的密文
		byte[] cipherByte = null;
		try {
			// 得到加密/解密器
			Cipher c1 = Cipher.getInstance(Algorithm);
			// 用指定的密钥和模式初始化Cipher对象
			// 参数:(ENCRYPT_MODE, DECRYPT_MODE, WRAP_MODE,UNWRAP_MODE)
			c1.init(Cipher.ENCRYPT_MODE, key, sr);
			// 对要加密的内容进行编码处理,
			cipherByte = c1.doFinal(info.getBytes());
		} catch (Exception e) {
			e.printStackTrace();
		}
		// 返回密文的十六进制形式
		return byte2hex(cipherByte);
	}
542855
public String getData(String key) {
        QName qn = new QName("data-" + key);
        return this.getOtherAttributes().get(qn);
    }
1046186
public static String encrypt(String key,String data) {
    	if(data == null)
    		return null;
    	try{
	    	DESKeySpec dks = new DESKeySpec(key.getBytes());	    	
	    	SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
	        //key的长度不能够小于8位字节
	        Key secretKey = keyFactory.generateSecret(dks);
	        Cipher cipher = Cipher.getInstance(ALGORITHM_DES);
	        AlgorithmParameterSpec paramSpec = new IvParameterSpec(IV_PARAMS_BYTES);;
	        cipher.init(Cipher.ENCRYPT_MODE, secretKey,paramSpec);           
	        byte[] bytes = cipher.doFinal(data.getBytes());            
	        return byte2hex(bytes);
    	}catch(Exception e){
    		e.printStackTrace();
    		return data;
    	}
    }
507277
public static String decrypt(String data, byte[] key)
    {
        try
        {
            Key k = toSecretKey(key);
            Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM);
            cipher.init(Cipher.DECRYPT_MODE, k);
            byte[] toByteArray = Hex.decodeHex(data.toCharArray());
            byte[] decrypted = cipher.doFinal(toByteArray);
            return new String(decrypted, "UTF-8");
        }
        catch (GeneralSecurityException e)
        {
            throw new RuntimeException("Failed to decrypt.", e);
        }
        catch (UnsupportedEncodingException e)
        {
            throw new RuntimeException(e);
        }
        catch (DecoderException e)
        {
            throw new RuntimeException(e);
        }
    }
853633
public String getMessage(String key, Object... params)
    {
        String message = getMessage(key);
        MessageFormat fmt = new MessageFormat(message);  
        return fmt.format(params);  
    }
448625
public static int getValueAsInt(byte[] key, Map<byte[], byte[]> infoValues) {
    byte[] value = infoValues.get(key);
    if (value != null) {
      try {
        int retValue = Bytes.toInt(value);
        return retValue;
      } catch (NumberFormatException nfe) {
        LOG.error("Caught NFE while converting to int ", nfe);
        return 0;
      } catch (IllegalArgumentException iae) {
        // for exceptions like java.lang.IllegalArgumentException:
        // offset (0) + length (8) exceed the capacity of the array: 7
        LOG.error("Caught IAE while converting to int ", iae);
        return 0;
      }
    } else {
      return 0;
    }
  }
827878
public int mandatoryParamAsInt(String key) {
    String s = mandatoryParam(key);
    return parseInt(key, s);
  }
955053
private String processKey(String key) {
        AssertUtils.assertNotNull(key, "Key cannot be null");

        String result = null;

        if (this.isCaseSensitive() == false) {
            result = key.toLowerCase(Locale.ENGLISH);
        } else {
            result = key;
        }

        return result;
    }
424039
public String getParam(final String key) {
        AssertUtils.notEmpty(key, "key must not be null or empty.");
        return mParams.get(key);
    }
1293109
public String getString(String key) {
        Object tmp = objectMap.get(key);
        return tmp == null ? null : tmp.toString();
    }
241458
private static String getInnerMapKey(final String key) {
        final int index = key.indexOf(".");
        return key.substring(index + 1);
    }
1008837
def get_info(self, key=None, Id=None) -> dict:
        """"""
        if key is not None:
            Id = self[key].Id
        return self.infos.get(Id,{})
443751
public String getRawComment(String key) {
        Entry entry = props.get(key);
        return entry == null ? null : entry.getRawComment();
    }
89958
public void info(Enum<?> key, Object... args) {
        if (!logger.isInfoEnabled()) {
            return;
        }
        String translatedMsg = imc.getMessage(key, args);
        MessageParameterObj mpo = new MessageParameterObj(key, args);

        if (instanceofLAL) {
            ((LocationAwareLogger) logger).log(LOCALIZED, FQCN, LocationAwareLogger.INFO_INT, translatedMsg, args, null);
        } else {
            logger.info(LOCALIZED, translatedMsg, mpo);
        }
    }
462820
@Override
    public long setInfo(String key, String info) {
        final String k = key;
        final String i = info;
        try {
            Status status = inTransaction(new Task() {
                @Override
                public Status run() {
                    try {
                        forest.rawPut("info", k, null, i == null ? null : i.getBytes());
                        return new Status(Status.OK);
                    } catch (ForestException e) {
                        Log.e(TAG, "Error in KeyStoreWriter.set()", e);
                        return ForestBridge.err2status(e);
                    }
                }
            });
            return status.getCode();
        } catch (Exception e) {
            Log.e(TAG, "Exception in setInfo()", e);
            return Status.UNKNOWN;
        }
    }
234857
public Date getDate(String key) {
    	String value = get(key);
        Date result = Utils.isEmpty(value)  ? null : Utils.dateFromString(value);
    	return result;
    }
425402
public String removeData(String key) {
        QName qn = new QName("data-" + key);
        return this.getOtherAttributes().remove(qn);
    }