We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4874d0b commit 77afe68Copy full SHA for 77afe68
1 file changed
README.md
@@ -109,9 +109,15 @@ if (MultihashCodec.SHA2_384.isEncoded(encoded)) {
109
...
110
}
111
112
+
113
/* get registry initialized with all multihash codecs */
114
var registry = MulticodecRegistry.getInstance(Tag.Multihash);
115
116
+/* determine digest index */
117
+var index = registry.getCodec(encoded)
118
+ .mapToInt(codec -> codec.length() + codec.digestLength(encoded))
119
+ .orElseThrow(() -> new IllegalArgumentException("Unsupported multihash."));
120
121
/* encode an input as multihash */
122
byte[] encoded = registry.getCodec(code)
123
.map(codec -> codec.encode(input))
0 commit comments