![JAR search and dependency download from the Maven repository](/logo.png)
org.bdware.dogp.client.CreateDOLParam Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doip-audit-tool Show documentation
Show all versions of doip-audit-tool Show documentation
doip audit tool developed by bdware
The newest version!
package org.bdware.dogp.client;
import org.apache.commons.codec.binary.Hex;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.digests.Blake2sDigest;
import java.nio.charset.StandardCharsets;
public class CreateDOLParam {
//TODO 引入type类型,然后不同type的字段会不同
public String dol;
public String spaceDOL;
public String originalId;
// 现在直接写ip:port
public String entranceDOL;
public String nextDOL;
public String calculateDOL() {
String dol = Hex.encodeHexString(blake2sHash(spaceDOL + ";" + originalId));
return dol;
}
public boolean verifyDOL() {
if (!calculateDOL().equals(dol)) {
return false;
}
return true;
}
public byte[] blake2sHash(String content) {
byte[] input = content.getBytes(StandardCharsets.UTF_8);
// 创建Blake2s哈希函数实例
Digest digest = new Blake2sDigest(128);
// 输入数据
digest.update(input, 0, input.length);
// 计算哈希值
byte[] hash = new byte[digest.getDigestSize()];
digest.doFinal(hash, 0);
return hash;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy