Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

442
Views
In Angular2 the SHA256 hash of a file generated does not match with SHA256 from other sites

I'm trying to generate SHA-256 hash for files.

I have used https://www.npmjs.com/package/crypto-js library for that. please see below code for that.

import { Component, OnInit } from '@angular/core';
var SHA256 = require("crypto-js/sha256");
@Component({
  moduleId: module.id,
  selector: 'dashboard',
  templateUrl: './dashboard.component.html',
  styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
  hash: string;
  constructor() { }
  ngOnInit() {}

  onFilesChange(fileList : Array<File>){
    this.fileList = fileList;
    console.log(fileList);
    for(var file in fileList){
      this.hash = SHA256(file);
      console.log(this.hash.toString());
    }

  }

}

File : file for sha-256 with above code I got below sh256 hash : 5feceb66ffc86f38d952786c6d696c79c2dbc239dd4e91b46729d73a27fb57e9

but I refer many online sites like http://onlinemd5.com/,http://www.online-convert.com/,https://md5file.com/calculator

form online site I got below sha256 hash : 27bb4358e847d559bed9f34eeee51ca71f51542afb0de4017b80dd66a0656eca

can anyone tell me why I'm getting different hash?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use:https://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-different-languages/#js

 <script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/hmac-sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/components/enc-base64-min.js"></script>

<script>
  var hash = CryptoJS.HmacSHA256("Message", "secret");
  var hashInBase64 = CryptoJS.enc.Base64.stringify(hash);
  document.write(hashInBase64);
</script>
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!