Skip to content

Commit e8bb202

Browse files
authored
fix(hash): updated sha1 with sha256 for file hash (#515)
* fix(hash): updated sha1 with sha256 for file hash
1 parent caf05c9 commit e8bb202

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Benchmark tests
1+
name: Benchmark
22

33
concurrency:
44
group: "benchmark-${{ github.ref }}"

code/go/0chain.net/blobbercore/filestore/fs_store.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package filestore
33
import (
44
"bytes"
55
"context"
6-
"crypto/sha1"
6+
"crypto/sha256"
77
"encoding/hex"
88
"encoding/json"
99
"fmt"
@@ -475,7 +475,7 @@ func (fs *FileFSStore) WriteFile(allocationID string, fileData *FileInputData,
475475

476476
fileRef := &FileOutputData{}
477477

478-
h := sha1.New()
478+
h := sha256.New()
479479
bytesBuffer := bytes.NewBuffer(nil)
480480
multiHashWriter := io.MultiWriter(h, bytesBuffer)
481481
tReader := io.TeeReader(infile, multiHashWriter)
@@ -548,7 +548,7 @@ func (fs *FileFSStore) WriteChunk(allocationID string, fileData *FileInputData,
548548
fileRef.ChunkUploaded = true
549549
}
550550

551-
h := sha1.New()
551+
h := sha256.New()
552552
size, err := dest.WriteChunk(context.TODO(), fileData.UploadOffset, io.TeeReader(infile, h))
553553

554554
if err != nil {
@@ -576,7 +576,7 @@ func (fs *FileFSStore) IterateObjects(allocationID string, handler FileObjectHan
576576
return nil
577577
}
578578
defer f.Close()
579-
h := sha1.New()
579+
h := sha256.New()
580580
if _, err := io.Copy(h, f); err != nil {
581581
return nil
582582
}

code/go/0chain.net/blobbercore/filestore/mock_store.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package filestore
22

33
import (
4-
"crypto/sha1"
4+
"crypto/sha256"
55
"encoding/hex"
66
"encoding/json"
77
"io"
@@ -31,7 +31,7 @@ func (ms *MockStore) WriteFile(allocationID string, fileData *FileInputData, inf
3131

3232
fileRef.ChunkUploaded = true
3333

34-
h := sha1.New()
34+
h := sha256.New()
3535
reader := io.TeeReader(infile, h)
3636
fileSize := int64(0)
3737
for {

0 commit comments

Comments
 (0)