I have to use bCrypt hash generator for encrypting any string.
Steps I have taken: #
1- Added Jar file in Lib folder
2- Restarted the Jmeter
3- Added below code in JSR223 Sampler
String password = "1234";
String bcryptHashString = BCrypt.withDefaults().hashToString(10, password.toCharArray());
- Exception Received
2023-10-06 13:27:53,749 ERROR o.a.j.p.j.s.JSR223Sampler: Problem in JSR223 script JSR223 Sampler, message: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: BCrypt for class: Script228 javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: BCrypt for class: Script228 at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.5.jar:3.0.5] at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.5.jar:3.0.5] at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_381] at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217) ~[ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.protocol.java.sampler.JSR223Sampler.sample(JSR223Sampler.java:72) [ApacheJMeter_java.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.1] at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.1]
I think you forgot to copy and paste the necessary
importstatementalso you need to add files, not the file, bcrypt won't work without bytes utility library
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?