File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
3+ */
4+ 'use strict' ;
5+
6+ const crypto = require ( 'isomorphic-webcrypto' ) ;
7+ require ( 'fast-text-encoding' ) ;
8+
9+ module . exports = {
10+ /**
11+ * Hashes a string of data using SHA-256.
12+ *
13+ * @param {string } string - the string to hash.
14+ *
15+ * @return {Uint8Array } the hash digest.
16+ */
17+ async sha256digest ( { string} ) {
18+ const bytes = new TextEncoder ( ) . encode ( string ) ;
19+ return new Uint8Array (
20+ await crypto . subtle . digest ( 'SHA-256' , bytes )
21+ ) ;
22+ }
23+ } ;
Original file line number Diff line number Diff line change 3030 ],
3131 "dependencies" : {
3232 "@digitalbazaar/security-context" : " ^1.0.0" ,
33- "jsonld" : " digitalbazaar/jsonld.js#v5.2.1-rc1" ,
33+ "fast-text-encoding" : " ^1.0.3" ,
34+ "isomorphic-webcrypto" : " ^2.3.8" ,
35+ "jsonld" : " digitalbazaar/jsonld.js#v5.2.1-rc2" ,
3436 "serialize-error" : " ^8.0.1"
3537 },
3638 "devDependencies" : {
7981 },
8082 "browser" : {
8183 "crypto" : false ,
82- "./lib/sha256digest.js" : " ./lib/sha256digest-browser.js"
84+ "./lib/sha256digest.js" : " ./lib/sha256digest-browser.js" ,
85+ "fast-text-encoding" : false ,
86+ "isomorphic-webcrypto" : false
87+ },
88+ "react-native" : {
89+ "crypto" : false ,
90+ "./lib/sha256digest.js" : " ./lib/sha256digest-reactnative.js" ,
91+ "./lib/sha256digest-browser.js" : false
8392 }
8493}
You can’t perform that action at this time.
0 commit comments