本文整理汇总了Java中org.apache.commons.codec.digest.DigestUtils.sha512Hex方法的典型用法代码示例。如果您正苦于以下问题:Java DigestUtils.sha512Hex方法的具体用法?Java DigestUtils.sha512Hex怎么用?Java DigestUtils.sha512Hex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.codec.digest.DigestUtils
的用法示例。
在下文中一共展示了DigestUtils.sha512Hex方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sha
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* @param message {@link String}
* @param type {@link HashType}
* @return {@link String}
*/
private static String sha(String message, HashType type) {
switch (type) {
case SHA1:
return DigestUtils.sha1Hex(message);
case SHA256:
return DigestUtils.sha256Hex(message);
case SHA512:
return DigestUtils.sha512Hex(message);
default:
return DigestUtils.sha256Hex(message);
}
}
示例2: computeFileDigest
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Computes the digest of the contents of the file this database belongs to.
*
* @return a digest, representing the contents of the file
* @throws IOException in the case of an error during IO operations
*/
private String computeFileDigest() throws IOException {
final BasicFileAttributes attr =
Files.readAttributes(Paths.get(fileDatabase.getFileName()), BasicFileAttributes.class);
return DigestUtils.sha512Hex(fileDatabase.getFileName() + attr.lastModifiedTime() + attr.size());
}
示例3: makeSignBySinpleFieldList
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* 根据SinpleField列表生成签名
*
* 加2个参数 delimiter,caseConvert
*
* @param fieldPaireds SinpleField的列表
* @param salt partnerApiKey
* @return 生成的签名字符串
*/
private static String makeSignBySinpleFieldList(List<FieldPaired> fieldPaireds, String salt,
Boolean excludeKeyParameter, SignatureAlgorithmic algorithmic, String saltParameterPrefix,
String charset, CaseControl caseControl, String delimiter) {
List<String> list = fieldPaireds.stream()
.sorted(new AsciiSortedComparator<>(FieldPaired::getProperty)).map(
FieldPaired::toString).collect(Collectors.toList());
//在对象上添加特殊属性, 当不排除时添加
if (!excludeKeyParameter) {
if (StringUtils.isEmpty(saltParameterPrefix)) {
throw new RuntimeException("指定了需要添加KEY=到salt前面, 却没有指定前前缀, 请检查官方文档,再做相应调整");
}
list.add(saltParameterPrefix + salt);
}
// 未加密字符串
String unencrypted = "";
try {
unencrypted = new String(String.join(delimiter, list).getBytes(), charset);
//将salt添加到最后面
if (!StringUtils.isEmpty(salt)) {
if (excludeKeyParameter) {
unencrypted += salt;
}
}
log.debug("Unencrypted String is: {}", unencrypted);
} catch (Exception e) {
e.printStackTrace();
}
String result = "";
switch (algorithmic) {
case MD2:
result = DigestUtils.md2Hex(unencrypted);
break;
case MD5:
result = DigestUtils.md5Hex(unencrypted);
break;
case SHA1:
result = DigestUtils.sha1Hex(unencrypted);
break;
case SHA256:
result = DigestUtils.sha256Hex(unencrypted);
break;
case SHA384:
result = DigestUtils.sha384Hex(unencrypted);
break;
case SHA512:
result = DigestUtils.sha512Hex(unencrypted);
break;
default:
throw new RuntimeException("不支持的签名类型");
}
if (null != caseControl) {
switch (caseControl) {
case TO_LOWER_CASE:
result = result.toLowerCase();
break;
case TO_UPPER_CASE:
result = result.toUpperCase();
break;
}
}
log.debug("Encrypted Signature is: {}", result);
return result;
}
示例4: Citizen
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public Citizen(String nombre, String apellidos, String email, Date fecha_nacimiento, String direccion_postal,
String nacionalidad, String numero_identificativo, String contrasena) {
this(nombre,apellidos,email,fecha_nacimiento,direccion_postal,nacionalidad,numero_identificativo);
this.contrasena= DigestUtils.sha512Hex(contrasena);
this.contrasena_NC=contrasena;
}
示例5: setContrasena
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public void setContrasena(String password) {
this.contrasena= DigestUtils.sha512Hex(password);
this.contrasena_NC=password;
}
示例6: encode
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
@Override
public String encode(final String password) {
CommonHelper.assertNotBlank("salt", salt);
return DigestUtils.sha512Hex(password + salt);
}
示例7: getSHA512
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
public String getSHA512() {
return DigestUtils.sha512Hex(sequence);
}
示例8: sha512Hex
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Calculates the SHA-512 digest and returns the value as a hex string.
*
* @param input the input
* @return the value as hex
* @since 4.2
*/
public static String sha512Hex(final String input) {
return DigestUtils.sha512Hex(input);
}
示例9: computeSHA512
import org.apache.commons.codec.digest.DigestUtils; //导入方法依赖的package包/类
/**
* Compute the SHA-512 Hash of a String.
* @param plaintext The raw text to be hashed.
* @return The has of the provided text.
*/
public static String computeSHA512(String plaintext) {
return DigestUtils.sha512Hex(plaintext);
}