MCPcopy Index your code
hub / github.com/ccxt/ccxt / bytesFromValue

Method bytesFromValue

java/lib/src/main/java/io/github/ccxt/Exchange.java:2639–2652  ·  view source on GitHub ↗
(Object value)

Source from the content-addressed store, hash-verified

2637 }
2638
2639 private static byte[] bytesFromValue(Object value) {
2640 if (value instanceof byte[]) return (byte[]) value;
2641 if (value instanceof String) {
2642 String s = (String) value;
2643 if (s.startsWith("0x") || s.startsWith("0X")) s = s.substring(2);
2644 if (s.length() % 2 != 0) s = "0" + s;
2645 byte[] out = new byte[s.length() / 2];
2646 for (int i = 0; i < out.length; i++) {
2647 out[i] = (byte) Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16);
2648 }
2649 return out;
2650 }
2651 throw new RuntimeException("Cannot interpret value as bytes: " + (value == null ? "null" : value.getClass()));
2652 }
2653
2654 private static byte[] keccak256(byte[] input) {
2655 org.bouncycastle.jcajce.provider.digest.Keccak.Digest256 k = new org.bouncycastle.jcajce.provider.digest.Keccak.Digest256();

Callers 1

encodeValueMethod · 0.95

Calls 2

parseIntMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected