上一個博客講了方式一:函數助手__digest加密,BeanShell PreProcessor也可以用java代碼進行處理
線程組、參數、請求都直接使用上一個博客的。
第一步 添加BeanShell PreProcessor
2 script中輸入代碼
import org.apache.commons.codec.digest.DigestUtils; //引入包 String str = vars.get("phone")+vars.get("password")+vars.get("usertype"); //取jmeter參數進行拼接 vars.put("beanshell_str",str); vars.put("beanshell_entrystring",DigestUtils.sha256Hex(str)); //加密,定義接受對應值的jmeter參數名
3 請求中引用參數
4 運行,結果樹查看結果。與方式一的加密串一致。
the end!