### Question:
EncryptionUtils { public static String encryptByPrivateKeyAsString(byte[] data, String sKey) { byte[] key = StringUtilsEx.decodeBase64(sKey); return StringUtilsEx.encodeBase64String(encryptByPrivateKey(data, key)); }  static AsymmetricKeyPair initAsymmetricKeyPair(); static byte[] encryptByPrivateKey(byte[] data, byte[] key); static String encryptByPrivateKeyAsString(byte[] data, String sKey); static byte[] encryptByPublicKey(byte[] data, byte[] key); static String encryptByPublicKeyAsString(byte[] data, String sKey); static byte[] decryptByPrivateKey(byte[] data, byte[] key); static byte[] decryptByPrivateKeyAsString(byte[] data, String sKey); static byte[] decryptByPublicKey(byte[] data, byte[] key); static byte[] decryptByPublicKeyAsString(byte[] data, String sKey); static byte[] encrypt(byte[] data, byte[] key); static String encryptWithBase64Key(byte[] data, String base64stringKey); static String encryptStringWithBase64Key(String sdata, String base64stringKey); static byte[] decrypt(byte[] data, byte[] key); static String decryptWithBase64Key(byte[] data, String base64stringKey); static String decryptStringWithBase64Key(String base64stringData, String base64stringKey); static final Charset DEFAULT_CHARSET; static final Charset ISO_8859_1; static final Charset UTF8; }### Answer:
@Ignore @Test public void testLoginWithSubSystemCode() { String loginEndPoint = "http: String subSystemCode = "SUB_SYSTEM_CODE_A"; String nonce = "123"; String plainPassword = String.format("%s:%s", subSystemCode, nonce); String cipherPassword = EncryptionUtils.encryptByPrivateKeyAsString(plainPassword.getBytes(EncryptionUtils.UTF8), privateKey); CredentialDto credential = new CredentialDto(); credential.setClientType(ApplicationConstants.ClientType.SUB_SYSTEM); credential.setNonce(nonce); credential.setPassword(cipherPassword); credential.setUsername(subSystemCode); RestTemplate restClient = new RestTemplate(); String responseBody = restClient.postForObject(loginEndPoint, credential, String.class); log.info("RESULT:/n{}", responseBody); }
@Test public void testEncryptByPrivateKeyAsString() { }