1

During API automation, I do have a requirement to encrypt the password and decrypt runtime just before using it in Karate.

Is there any specific inbuilt method available to do so?

If it is not available, can anyone please guide me on how to do this?

Vishal Shah
  • 47
  • 1
  • 7

1 Answers1

1

There's nothing built into Karate because you can easily plug in anything via Java interop: https://github.com/intuit/karate#http-basic-authentication-example

You can find plenty of Java code examples that will do what you want.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    Thanks, Peter. I understood. I'll try and will get back to you in case of any difficulties. – Vishal Shah May 08 '20 at 13:32
  • Using your suggested method, I am able to get an encrypted string. however, while trying to decrypt that encrypted string, I am facing an error. Below is my code snapshot var Base64 = Java.type('java.util.Base64'); byte[] actualByte = Base64.getDecoder().decode(str); String actualString = new String(actualByte); return actualString; Error I am getting is, on byte[] Expected an operand but found ] – Vishal Shah May 10 '20 at 17:29
  • @VishalShah this is just a matter of using Java. but please ask a new question and keep it clear and simple, but I strongly suggest you follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas May 10 '20 at 17:33
  • Acknowledged Peter. I'll ask new question. – Vishal Shah May 10 '20 at 17:36