fromContent static method

Future<CID> fromContent(
  1. Uint8List data, {
  2. String codec = 'raw',
})

Creates a CID by hashing data with SHA2-256.

The codec defaults to raw.

Implementation

static Future<CID> fromContent(Uint8List data, {String codec = 'raw'}) async {
  final digest = sha256.convert(data).bytes;
  final mh = MultihashUtils.sha256(Uint8List.fromList(digest));
  return CID.v1(codec, mh);
}