解决了

SHA512 Neoload打来的电话

  • 2023年7月26日
  • 2回答
  • 6的观点

Userlevel 5
徽章 + 2
  • 社区经理
  • 72回复

团队,

我有一个要求加密密码使用Neoload SHA512之前调用登录请求。谁能分享你的经验如何最好我们可以做同样的事情?

(最初要求和解决支持中心)

图标

最佳答案社区管理员2023年7月26日,十七24

Here's some JavaScript code that could work for you:<\/p>
\/\/ Get variable value from VariableManager
var MYPASSWORD = context.variableManager.getValue(\"myPassword\");

\/\/ Function to encrypt into sha512
function sha512(password) {
var hash = java.security.MessageDigest.getInstance(\"SHA-512\");
var encodedPassword =
java.nio.charset.StandardCharsets.UTF_8.encode(password);
hash.update(encodedPassword);
var encryptedPassword = hash.digest();

var hexString = new java.lang.StringBuilder();
for (var i = 0; i < encryptedPassword.length; i++) {
var hex = (encryptedPassword[i] & 0xff).toString(16);
if (hex.length === 1) {
hexString.append('0');
}
hexString.append(hex);
}

return hexString.toString();
}

\/\/ Run the function
const hashedPassword = sha512(MYPASSWORD);

\/\/ Log out for debugging (optional)
logger.error(\"SHA512=\"+hashedPassword);

\/\/ Inject the computed value in a runtime variable
context.variableManager.setValue(\"myPassword\",hashedPassword);<\/code><\/pre>

Here's an example my setup:
\"6f64546c335be110b8c0c37c2d5c7b47.iix\"<\/p>

Then, when I run it (just doing a mock up post to google), I can see the password is correctly encrypted to sha512:
\"25f45c6c335be110b8c0c37c2d5c7b89.iix\"

I can verify this using\u00a0https:\/\/caligatio.github.io\/jsSHA\/<\/a>\u00a0and plugging in my password (abcxyz123).\u00a0 It's the same number (starts with 24bf9c...):
\"4875946c335be110b8c0c37c2d5c7b03.iix\"

HTH,<\/p>","className":"post__content__best_answer"}">

查看原始

2回答

Userlevel 3
徽章 + 2

这里有一些JavaScript代码,可能为你工作:

/ /从VariableManager获取变量值
var我的密码= context.variableManager.getValue(“我的密码”);

/ /函数向sha512加密
函数sha512(密码){
var散列= java.security.MessageDigest.getInstance (sha - 512);
var encodedPassword =
java.nio.charset.StandardCharsets.UTF_8.encode(密码);
hash.update (encodedPassword);
var encryptedPassword = hash.digest ();

var hexString = new java.lang.StringBuilder ();
(var = 0;我< encryptedPassword.length;我+ +){
var十六进制= (encryptedPassword[我]& 0 xff) .toString (16);
如果(十六进制。长度= = = 1){
hexString.append (“0”);
}
hexString.append(十六进制);
}

返回hexString.toString ();
}

/ /运行功能
const hashedPassword = sha512(我的密码);

/ /退出调试(可选)
logger.error (“SHA512 = " + hashedPassword);

/ /将计算值在一个运行时变量
context.variableManager.setValue(“我的密码”,hashedPassword);

这里有一个例子我的设置:
6 f64546c335be110b8c0c37c2d5c7b47.iix

然后,当我运行它(谷歌只是做一个模拟的帖子),我可以看到密码正确sha512加密:
25 f45c6c335be110b8c0c37c2d5c7b89.iix

我可以使用证明这一点https://caligatio.github.io/jsSHA/插入我的密码(abcxyz123)。是一样的(从24 bf9c…)数量:
4875946 c335be110b8c0c37c2d5c7b03.iix

HTH,

Userlevel 5
徽章 + 2

太好了。谢谢你的快速反应。它工作。

回复


Learn more about our cookies.<\/a>","cookiepolicy.button":"Accept cookies","cookiepolicy.button.deny":"Deny all","cookiepolicy.link":"Cookie settings","cookiepolicy.modal.title":"Cookie settings","cookiepolicy.modal.content":"We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.<\/a>","cookiepolicy.modal.level1":"Basic
Functional","cookiepolicy.modal.level2":"Normal
Functional + analytics","cookiepolicy.modal.level3":"Complete
Functional + analytics + social media + embedded videos"}}}">
Baidu
map