[#1] Define SDK structure, add operations with container and object

Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
Ori Bruk 2024-06-11 17:34:39 +03:00
parent 04bf8249c2
commit 2481774545
80 changed files with 6315 additions and 0 deletions

View file

@ -0,0 +1,36 @@
package info.FrostFS.sdk;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.ByteString;
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 byte[] getSha256(byte[] value) {
try {
return MessageDigest.getInstance("SHA-256").digest(value);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static ByteString getSha256(AbstractMessage value) {
return ByteString.copyFrom(getSha256(value.toByteArray()));
}
public static String пуеHexString(byte[] array) {
return String.format("%0" + (array.length << 1) + "x", new BigInteger(1, array));
}
}