Ask a Question

Base64 decode password

SOLVED
Said
Contributor

Base64 decode password

Hi All,

 

I have a a project property that has a password that I use in a request. In the password field of the request I use syntax below to get password in request:

${#Project#servicePwd}

This works perfect. Now I would like to use base64 encoded password and decode this password with syntax below:

${=java.util.Base64.getDecoder().decode(${#Project#servicePwd})}

But When I use this syntax I get invalid userid / password error. What am I doning wrong? How can I use encoded passwords?

 

Thanks in advance!

5 REPLIES 5
Radford
Super Contributor

Just to clarify, when you say "I would like to use base64 encoded password and decode" do you mean that the property ${#Project#servicePwd} is a Base64 encoded string and you want to convert this to plan text to send to your service, or vice versa?

 

As an aside Groovy contains it's own methods to encode & decode Base64 strings, you shouldn't need to use the java.util library. See the following page for details:

 

http://mrhaki.blogspot.com/2009/11/groovy-goodness-base64-encoding.html

Exactly, I want to decode the password stored in ${#Project#servicePwd}

 

And thanks for the groovy tip. I will look into it.

Radford
Super Contributor

Just one more point, I was wondering why you had a Base64 encoded property? Are you just trying to obscure the password, so somebody can't just view it? If so are you aware that Ready API has several feature to protect sensitive data? I've personally never used them, but they are described on the following page:

 

https://support.smartbear.com/readyapi/docs/testing/best-practices/secure.html

 

In particular check out the section "Encrypt Individual Properties".

Yes I want to obscure the password. 

Thanks for the link, I am aware of these options. I don't want to use password protected projects (as described in the links).

groovyguy
Champion Level 0

I think you could get what you want with this snippet of code:

 

${= new String (context.testCase.testSuite.project.getPropertyValue("servicePwd").decodeBase64() )}



---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
cancel
Showing results for 
Search instead for 
Did you mean: