(Object value)
| 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(); |
no test coverage detected