@Test public void testencrypt() { String pwd = EncryptionUtil.encrypt("-----BEGIN RSA PRIVATE KEY-----\n" + "FUCKogIBAAKCAQEAzuswWPArXG6aShTC3ax63+pYOgYYe51YeICqBzOmcAv8MXWD\n" + "wIQR/xlpzLQVlW198RKiOnvAt/8YWIJ261XnxhGM/zNpKM0ZWBRCNqsAC6XKJbPC\n" + "sY9SQASaKAmhB9m8IQzQvKOd0MxVmZ8FGDQdggYEtXqaUI3ypcc79A0bY53CJJI3\n" + "FEZYZ8uVwxDy1B4fLQAzBadxqxmVBtGpP+GRHKzc6RkUoiNvBWY+mVUEdBe+auRR\n" + "/gZ3OdSbuoXMJPTfnjqEvMU/QEpzMF1+2Abu+X+y/l+0zJ+b2exCff5f1Fx5s0NT\n" + "GleqBt0SLul0+Naha5fcdnpQWBrCe26fkKycYwIBIwKCAQEAq3Jp40qnlbq6WqN8\n" + "447pd7OK7j+QoPAWGrPAFJiCl1pjPuxXORz49/B8O+Wre8/AH4R3yg7EQK7LB4IK\n" + "wv4JLxXbOdoj7ptPg36AAWkdS3q9b7Izmm9wCShiePIJFSIfiRk/PTccXIwMaVff\n" + "plb5pnoD5tNMqSUoIvWJcnFClFym38v31yActsBhXdggetnNm/R6fsFVZ6QPwdjV\n" + "kcqDWzDZobSN9NV5ihzWVy1/2VcLDs1v9yBY4BdOsNbj4RIO178duLKZQu5QOv3B\n" + "j5tdZa3O4JPgtj0if3sAP8hci6sM5G0DN7Dw5HlxBDXkuj50sMKWVtb3jyb5EIfn\n" + "spusKwKBgQDujV2SeTtIM5C+UYFoKdFCcs/W6hq0t/DKpMNXCuFPD3S4AJWFLEXh\n" + "ciBQNmyJlG1kzQ1pPeqhRt5M51bDDjQzkYQXDRVJQc5TeRhV03L00LSRN7EAd3rn\n" + "gGZDfoPwJvXptu4stPkwawpvjRw6WdeXPkd9/Fb6PZkkPkZfdt7yMQKBgQDeDYUY\n" + "YnGMciaFQBXWCVemyQB40gCCA1EhS/b4LMU5llV2hnSvKxDgaCv0hu+GKM6KEGNh\n" + "ne4s5IHnBpWdyVKaIs/FZthpKDrZXmstwTC+Z3TzIZJM2k2uBknSjzBYQqDzL0RX\n" + "em5xW/CepYwvZ500hB7m04nTDKIHtnKSZY1e0wKBgA2hrZNXYnenhJ0pOpg852Lh\n" + "/T97F3gKgEnARa0z0lxKBqttv2ayEp8rF8oRvQ8tDZC7QphMuUsLXSj3RslRRM+/\n" + "LB6TCIfX3+eDQzgathyeNjQvEW29r0BtvLNmUK6jI/65/vs9ipUNbk+EaANVftkZ\n" + "gG2ZZA5MqapMs5BtMU+rAoGAEwh5H1jlKUuc5tmbeL744mkAClsknW3/o8SuxNCj\n" + "MNJfGMmyOuZvKS2AHEYUh9ecrL+TfWVO7eezXPHvkS6DbEwgcAGAQ4cyTSVZpNYL\n" + "fgjeI3fn9/V031+f7Xn81F17go8F25zHo1EF/vg/N0NlPwQCphIhwaH/Qn1aRxAE\n" + "zZ0CgYEAti0Fne7isUzcS3RfZn2/uMHKglwSn/FLTrkdNtElTd58U78iV8tsGKg0\n" + "nlZ9ppZ3ZlOU91OE6LFDgV7yQe1YwWvKUFgXvzRDi/Y6zw+9ufaW9RobYajxOkeh\n" + "aakZWj7qbK16/88PTP8Sk91OzIWF5TSpW834/Yua/SckAdYPYcU=\n" + "-----END RSA PRIVATE KEY-----\n"); System.err.println(pwd); }
public static String encrypt(String str) { String retVal = null; if (str != null && str.length() > 0) { try { Cipher c = Cipher.getInstance(CRYPT_ALGORITHM); c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, CRYPT_ALGORITHM)); byte[] encVal = c.doFinal(str.getBytes()); retVal = new String(Base64.encodeBase64(encVal)); } catch (Exception ex) { log.error(ex.toString(), ex); } } return retVal; }
EncryptionUtil { public static String encrypt(String str) { String retVal = null; if (str != null && str.length() > 0) { try { Cipher c = Cipher.getInstance(CRYPT_ALGORITHM); c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, CRYPT_ALGORITHM)); byte[] encVal = c.doFinal(str.getBytes()); retVal = new String(Base64.encodeBase64(encVal)); } catch (Exception ex) { log.error(ex.toString(), ex); } } return retVal; } }
EncryptionUtil { public static String encrypt(String str) { String retVal = null; if (str != null && str.length() > 0) { try { Cipher c = Cipher.getInstance(CRYPT_ALGORITHM); c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, CRYPT_ALGORITHM)); byte[] encVal = c.doFinal(str.getBytes()); retVal = new String(Base64.encodeBase64(encVal)); } catch (Exception ex) { log.error(ex.toString(), ex); } } return retVal; } private  EncryptionUtil(); }
EncryptionUtil { public static String encrypt(String str) { String retVal = null; if (str != null && str.length() > 0) { try { Cipher c = Cipher.getInstance(CRYPT_ALGORITHM); c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, CRYPT_ALGORITHM)); byte[] encVal = c.doFinal(str.getBytes()); retVal = new String(Base64.encodeBase64(encVal)); } catch (Exception ex) { log.error(ex.toString(), ex); } } return retVal; } private  EncryptionUtil(); static String generateSalt(); static String hash(String str, String salt); static String hash(String str); static String encrypt(String str); static String decrypt(String str); }
EncryptionUtil { public static String encrypt(String str) { String retVal = null; if (str != null && str.length() > 0) { try { Cipher c = Cipher.getInstance(CRYPT_ALGORITHM); c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, CRYPT_ALGORITHM)); byte[] encVal = c.doFinal(str.getBytes()); retVal = new String(Base64.encodeBase64(encVal)); } catch (Exception ex) { log.error(ex.toString(), ex); } } return retVal; } private  EncryptionUtil(); static String generateSalt(); static String hash(String str, String salt); static String hash(String str); static String encrypt(String str); static String decrypt(String str); static final String CRYPT_ALGORITHM; static final String HASH_ALGORITHM; }