@Test public void testencryptByToy() { String pwd = EncryptionUtil.encrypt("-----BEGIN RSA PRIVATE KEY-----\n" + "FUCKoQIBAAKCAQEAsYyt2cnUkg3CcUtgWtTlb9MWXc/ub5dTgF4HjJferQp6NHzl\n" + "DvTZzVM3AUi2ZCoz7KuFZ22yRvAN69/1lUs4sk/V73kxFmuN/6ZziquAptypqoEN\n" + "L8FypPSpcfAU1d1HMtbI/XKQcMbHkxI9jyiAFHHHJkzwYB7LYEWUcTr0iJbBgYO6\n" + "/b6tBnXacx1IoPLF2fPov2D4W6NlYrF4JlviEA504dDYky0YQHrOpqDEPhEVU1ON\n" + "c6FVXNeXbxdONyH5gcpLgR8g0nHXPlC4phhow0CAzZLxAxEFSDwppCms36NLUaCc\n" + "c9wcI8bsA68ELL2vvP7qMWraqAk+rCfg2qRC0QIBIwKCAQEAnUIWUy8bXMpbw26l\n" + "zMsxnY8Tz28GYtZ9KI3MHBF8FZuQz2dOiZcKDaF53JDcD5MYDCLj30PnC6FraoSJ\n" + "DzP/BFVXFe7/l4PViqUfBcsaLWRbwudU0obEoLtxgixqOcP9O6hLnqdMu6jOc6Jx\n" + "CcTJNq3q52i3pZeeMLKoDISss3y8f9fzBi2xEc2IpZq9+BxSlyf95ihSQuAOLqNI\n" + "NpJxDmDOkbtFl5bdTBLYmhcRa9Nco7IASyGdgWDRsY2Q+89bqvLcMIJSKzwWLttg\n" + "tJE4JFJIkYDG3Rott1Nc3FCVHqHvd7bq7p5fdICbvkXsUAPlXnLqdkpWgzTWqfct\n" + "uLKbiwKBgQDcQ8iU4N/ezFY3NICY7crLorEH/GJemd/DBOMTM2heZuuQ7/K3Fgk7\n" + "bP42tf2I6RzZh+Dqf+UaTXiuCCKnWxULvB6a471EpbNtC5uZ+xUIM7y3+fMhk/hJ\n" + "ZpiYzvmRhGsRu5klzRPxI538qC+4SVUDf6uLzNsOAoJbDiJmBA5fwQKBgQDOWs+X\n" + "3BaSsmkhvXIbSHNa53CQjZdFI63k71gbrRRe2veoJAqx4oHKM0ZIjHzM0vUV5C3L\n" + "6TtwdPpJCdjypvmGRrqGdyFN2uXuDlIUlNMIZoG49YpJv9ZhCmZ6kh9y/tP5q8VU\n" + "oaG/Oo95Ux/Vup4UoSQ0pTOchQDo/yg2s3mnEQKBgFHQCKxThloRYdn9jtm3aJTH\n" + "ZlNsXw0x1sTHTQchuQ0e6cgem/rcTJHqT8stp1AcEgenf20K7rH/hJhpa/UEksnY\n" + "KJ/uMFtTfSiAp4JV8d55nd3vH8qkrK2MgdJbgUSthtqzZMTlxZQUiyNUaX72qoxF\n" + "XPlpWK1upUJHFBdDVcvLAoGAEbADKkYQkDstlS1+zyN3mhPWcspOy2l1TiMkzywX\n" + "sFvpV44Pi5cScGrLgo+95auum3n1S/4MaLmRy78D94qnrGx2Y0wKKz6l/nZBjLxM\n" + "mlHt3KdU/wHQi/mTwVz7YaDQVzqb4q7EuJ6elV7leLg5b3uGwq8TDWp8a74ZY8Y9\n" + "oJsCgYAdQ5QQFrkXVG/DK4hcUwb8CeOu30PQBaAEyN/3qIQBGFeJ4RMd4/iCwdSv\n" + "HGq/61cBe/mR2v7XXf3vFD3ea+vF7sFZTh1pYsHn/mK8Go5c4utqakatY+LLcHE4\n" + "XSIoTLTx3Kwt1roUXwlyHp8VoxGKyznBZ72/6NQrw4nuiV459U==\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; }