[#1] provide naming conventions

Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
Ori Bruk 2024-07-23 22:24:17 +03:00
parent a7fab6f314
commit bf2f19f08d
103 changed files with 416 additions and 417 deletions

View file

@ -0,0 +1,40 @@
package info.frostfs.sdk;
import com.google.protobuf.ByteString;
import com.google.protobuf.Message;
import org.bouncycastle.crypto.digests.RIPEMD160Digest;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class Helper {
public static byte[] getRIPEMD160(byte[] value) {
var hash = new byte[20];
var digest = new RIPEMD160Digest();
digest.update(value, 0, value.length);
digest.doFinal(hash, 0);
return hash;
}
public static MessageDigest getSha256Instance() {
try {
return MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static byte[] getSha256(byte[] value) {
return getSha256Instance().digest(value);
}
public static ByteString getSha256(Message value) {
return ByteString.copyFrom(getSha256(value.toByteArray()));
}
public static String getHexString(byte[] array) {
return String.format("%0" + (array.length << 1) + "x", new BigInteger(1, array));
}
}