How to extract values from CSV file outside the scenario

Hi,

We are doing AES encryption of username & password for login transaction. We have written a custom code outside the scenario where we have defined a constant value(1001 & 123). Now, we want to parameterize those values by using csv file, how can we achieve that here ?

Encryption code:-

val text1toEncrypt = “1001”
val text2ToEncrypt = “123”
val secret = “secretkey”
val IvParameterSpec = “Ivparamspec”
val cipher = Cipher.getInstance(“AES/CBC/PKCS5Padding”, “SunJCE”)
val key = new SecretKeySpec(secret.getBytes(“UTF-8”), “AES”)
val IvParameterSpec1 = new IvParameterSpec(IvParameterSpec.getBytes(“UTF-8”))
cipher.init(Cipher.ENCRYPT_MODE, key, IvParameterSpec1 )
println(“Chithra”+cipher)
def uname = cipher.doFinal(text1toEncrypt.getBytes(“UTF-8”))
def pass = cipher.doFinal(text2ToEncrypt.getBytes(“UTF-8”))
def Username = Base64.getEncoder.encodeToString(uname)
def Password = Base64.getEncoder.encodeToString(pass)
println(“Final_username” + Username)
println(“Final_password” + Password)
private val scn = scenario(“MHC”)

Please help us on urgent basis.

What do you mean exactly by “parameterize”?
Do you want:

  1. all virtual users to use the same values?
  2. each virtual user to use distinct values?

Regards

Asking for each virtual user to use distinct values.

Where do text1toEncrypt and text2toEncrypt come from? A feeder? If so, the most efficient way to be to have the encrypted values directly inside the CSV file.

A feeder wasn’t working outside the scenario. I was using below mention code:

val login = csv(“login_credentials.csv”).circular()
feed(login)
def text1toEncrypt = “${user}”
def text2ToEncrypt = “${password}”
val secret = “secretkey”
val IvParameterSpec = “Ivparamspec”

I’m telling you to prepare the encrypted data upfront if your CSV file so that you don’t burn CPU and block threads on this at runtime.