Last active
          November 3, 2023 17:51 
        
      - 
      
 - 
        
Save saintplay/4cc46f98d52534941c807572019ad239 to your computer and use it in GitHub Desktop.  
    Get SHA-256 from asset
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fetch('/assets/app.bundle.js') | |
| .then(response => { if (response.status > 200) throw new Error('not found'); return response.arrayBuffer() }) | |
| .then(async (buffer) => { | |
| const hashBuffer = await crypto.subtle.digest('SHA-256', buffer); | |
| const hashArray = Array.from(new Uint8Array(hashBuffer)); | |
| return hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join(''); | |
| }) | |
| .then(console.log) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment