Answered question

Login Password Encryption With RSA Key

Each Time user login encrypted password is going to the server. I have tried to generate the encrypted password as adding a java script action and inside the javascript action I have written the below code. While trying to execute I am getting the error ReferenceError: "RSAKey" is not defined. I am very new to neoload. Can you please suggest how to resolve this

var publicKey = new RSAKey();

context.variableManager.setValue("c_modulusHexString",c_modulusHexString);
context.variableManager.setValue("c_publicExponentHexString",c_publicExponentHexString);
publicKey.setPublic(c_modulusHexString, c_publicExponentHexString);
var initSecureRandom = new SecureRandom();
var result = publicKey.encrypt(MyPassword);
var Password= hex2b64(result);

context.variableManager.setValue("Password",Password);

Shareena R.
Shareena R.

Shareena R.

Level
0
17 / 100
points
Neil W.
Neil W.

Neil W.

Level
3
4082 / 5000
points
Team

I've never dropped them directly in this folder, I normally do it via the GUI, under edit > JS Libraries. You shouldn't need all the js downloaded by your app. just the bit related to RSAKey. As mentioned before, because this is a class/type, it may be that you actually need some JAR files that contain this class definition.

Did you find this useful ?

No (0)

Yes (0)

0% of users found this answer useful

Other answers

Neil W.
Neil W.

Neil W.

Level
3
4082 / 5000
points
Team

You would get an error as the Neoload JS engine doesn’t know what RSAKey is, the line is the same as var fruit = new banana();

You need to include the library where RSAKey is defined, I assume that it is inside one of the JS files downloaded by the client. Look in you script for it using the flag feature.

Neil W.
Neil W.

Neil W.

Level
3
4082 / 5000
points
Team

If it’s not there, maybe you need to include the jar file containing the class

Shareena R.
Shareena R.

Shareena R.

Level
0
17 / 100
points

Hi Neil,

Thanks a lot for your input. I have downloaded the js files and added the js under \lib\jslib. How do I import this in my javascript action?

Is there alternate way to do this?