-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathipfs_hash.html
More file actions
34 lines (31 loc) · 1.22 KB
/
ipfs_hash.html
File metadata and controls
34 lines (31 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/index.min.js"> </script>
<script src="https://bundle.run/buffer"></script>
<script src="https://unpkg.com/ipld-dag-pb/dist/index.min.js"> </script>
</head>
<body>
<h1>IPFS hash</h1>
test
<pre id="log" style="width:100%;height:200px"></pre>
<script type="text/javascript">
function log(logstr) {
document.getElementById("log").innerHTML +=logstr+"\n";
}
console.log("Start");
const Buffer=window.buffer.Buffer;
var sDataToHash="Web3examples \r\n"
var bufDataToHash = Buffer.from(sDataToHash+"\n");
console.log(bufDataToHash)
var unixFs = new window.IpfsUnixfs('file', bufDataToHash);
console.log(unixFs)
var ufsDataToHash=unixFs.marshal();
console.log(ufsDataToHash);
console.log(IpldDagPb)
var dd=new window.IpldDagPb.DAGNode();
console.log(dd)
var dagNode = window.IpldDagPb.util.cid(ufsDataToHash).then(x=> console.log(String.fromCharCode.apply(null, x)));
console.log(dagNode) // werkt niet
</script>
</body>
</html>