[英]How to generate sha512 hash with a salt using command line?
I use the below Java snippet to generate a hash password using an input and salt. 我使用下面的Java代码段使用输入和salt生成哈希密码。 Is there a way I can get that in Linux command line?
有什么办法可以在Linux命令行中得到它吗?
public String getPwd(String input, String salt) {
MessageDigest md = MessageDigest.getInstance("SHA-512");
md.update(salt.getBytes(StandardCharsets.UTF_8));
byte[] pwd= md.digest(input.getBytes(StandardCharsets.UTF_8));
System.out.println(Base64.encodeBase64URLSafeString(pwd));
}
You can use sha512sum
. 您可以使用
sha512sum
。
cat salt.dat myfile.dat | sha512sum -b
Seems the -b
is required for binary input (defaults to text, which can potentially result in different checksums depending on the encoding). 似乎
-b
是二进制输入所必需的(默认为text,根据编码可能会导致不同的校验和)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.