Comments (8)
Yes, that is strange and should not happen. Do you have a reproducible case?
from blake2.
In Python I used following and it always failed:
BLOCKSIZE = os.statvfs(os.getcwd()).f_bsize # determine optimal/prefered block size of file system
with open(f, 'rb') as afile:
buf = afile.read(BLOCKSIZE)
chk.update(buf)
l[f] = chk.hexdigest()
afile.close()
It automatically detects file system block size...my Apple SSD has got 1MB whereas external HDD has got 65kB for example. Unless, both blocksizes are not equal there is problem as confirmed by using official b2sum.
Ever since I use fixed blocksize
all seems to be ok until I used b2sum
. I noticed in b2sum
source code there is buffer size of 37kB or so.
Hard to say what happen if you play with buffer/blocksize on different OS
Of course it may be some multiOS issue as well !
Blake2 is not official under macOS and it has been installed by brew install coreutils
Python Blake2 implementation is considered as extra compared to core hash functions. Various Python OS implantation give different names fro Blake2, which should be no issue.
from blake2.
I'm not sure how to reproduce this. Does the following script fail for you? (Feel free to adjust parameters or sizes as you please)
from hashlib import blake2b
import os
MAX_LEN = 1234
DATA = os.urandom(MAX_LEN)
reference = blake2b(DATA).digest()
for step in range(1,MAX_LEN):
obj2 = blake2b()
for chunk in [DATA[i:i+step] for i in range(0, len(DATA), step)]:
obj2.update(chunk)
assert(obj2.digest() == reference)
print("ok")
from blake2.
your script prints ok
where I use it is as following:
- read list of files inside source directory (usually on CF card from camera)
- create hash for each file as shown in function above by [still in source path]
- copy files to destination (usually SSD)
- create checksum fo copied files [destination path]
- compare checksum created in source and destination
In other words if I create checksum of file in source with read blocksize 1MB
and check the very same file in destination path but read blocksize different than 1MB
- checksum fails.
from blake2.
BLOCKSIZE = os.statvfs(os.getcwd()).f_bsize # determine optimal/prefered block size of file system
with open(f, 'rb') as afile:
buf = afile.read(BLOCKSIZE)
chk.update(buf)
l[f] = chk.hexdigest()
afile.close()
I assume this is the correct indentation? If so, aren't you just reading the first BLOCKSIZE
bytes of the file?
from blake2.
Last two lines false indentation, it suppose to be in cycle as above by.
I have no idea, I used this code from some guy on internet. It suppose to read file by chunks defined by blocksize. If you don't specify blocksize/buffer it reads whole file into memory...I often copy larger files than my 16GB RAM.
https://docs.python.org/3.4/library/io.html?highlight=io#io.BufferedIOBase.read
from blake2.
To hash the entire file, you have to do something like
with open(f, 'rb') as fd:
chk = blake2b()
while True:
chunk = fd.read(BLOCKSIZE)
if not chunk:
break
chk.update(chunk)
print(chk.hexdigest())
So I don't think blake2 is the problem here.
from blake2.
thanks for info, I will try.
from blake2.
Related Issues (20)
- OID for blake2s? HOT 1
- Update binaries at blake2.net
- Porting on SPARC CPU HOT 3
- 'b2sum' names conflict HOT 1
- Tree test vectors missing
- Keyed hash test case for an independent implementation HOT 3
- Diagonal shuffle optimization for BLAKE2s
- blake2 HOT 1
- Any plan to make a new release? HOT 4
- Autotools configure.ac and Makefile.am
- Support for Apple Silicon on macOS (mach-o ARM64) HOT 2
- Status of blake2.net implementation list
- Provide a reference implementation for BLAKE2sp and BLAKE2bp in Java
- npm-gyp failer to rebuild blake2 HOT 1
- Include Blake2x HOT 1
- Question: What is the maximum key lenght that BLAKE2x can proccess?
- Questions about Blake2x: Its state size (internal state) and its security when generating keys with size more than 256/512bits HOT 1
- Question: Where do IV values come from? HOT 3
- Reference Implementation for Blake2 parameter block HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blake2.