A music player that connects to your cloud/distributed storage.
1import * as CID from "@atcute/cid";
2import { equals, toSha256 } from "@atcute/uint8array";
3
4/**
5 * @param {0x55 | 0x71} code
6 * @param {Uint8Array<any>} data
7 */
8export async function create(code, data) {
9 const cid = await CID.create(code, data);
10 return CID.toString(cid);
11}
12
13/**
14 * @param {Uint8Array<any>} data
15 * @param {string} expected
16 */
17export async function verify(data, expected) {
18 const expectedCid = CID.fromString(expected);
19 const digest = await toSha256(data);
20
21 return equals(digest, expectedCid.digest.contents);
22}