Skip to content

Instantly share code, notes, and snippets.

@mnogu

mnogu/main.go Secret

Last active May 17, 2023 14:26
Show Gist options
  • Save mnogu/19aa5ee2eaf4853eadd4fe20309a345c to your computer and use it in GitHub Desktop.
Save mnogu/19aa5ee2eaf4853eadd4fe20309a345c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
cid "github.com/ipfs/go-cid"
)
func main() {
data := []byte{
0x0, // the Multibase identity prefix (0x00)
0x1, 0x71, 0x12, 0x20, 0xb6, 0xf0, 0x94, 0x7e, 0x0,
0xac, 0x4c, 0x9b, 0xc9, 0xa1, 0x1c, 0x1, 0x6a, 0x4a, 0xa9,
0x9d, 0x33, 0x8d, 0xd6, 0x79, 0xd4, 0x33, 0x90, 0x10, 0xce,
0xb, 0x0, 0x27, 0xe0, 0xce, 0x5c, 0xc6,
}
_, cid, err := cid.CidFromBytes(data[1:])
if err != nil {
log.Fatal(err)
}
fmt.Println(cid)
}
# pip install py-multiformats-cid
from multiformats_cid import from_bytes
def main():
cidbytes = (b'\x00\x01\x71\x12\x20\xb6\xf0\x94\x7e\x00'
b'\xac\x4c\x9b\xc9\xa1\x1c\x01\x6a\x4a\xa9'
b'\x9d\x33\x8d\xd6\x79\xd4\x33\x90\x10\xce'
b'\x0b\x00\x27\xe0\xce\x5c\xc6')
print(from_bytes(cidbytes[1:]))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment