views:

299

answers:

3

I can see the SHA-1 of my blobs in the datastore viewer on live google app engine.

Is there a recommended way I can access the SHA-1 hash (or any other hash) of a blob programmatically in GAE?

A: 

Have you looked at the module hashlib? It has a sha1() function.

jbochi
+1  A: 

Do you mean the BlobKey? If so, just pass it to str(). Otherwise just generate a hash yourself with hashlib.

Bob Aman
Is the BlobKey a hash? Like if two images are identical, will the BlobKey be the same?
bobobobo
I'm not sure. Test it. Documentation doesn't say. I'm guessing no though. Consider what would happen if two people uploaded the same image. That behavior would cause both images to resolve to a single entry in the blob store. If you want a content-based hash, use `hashlib`, store the hashes as `hexdigest`, and be careful with your CPU usage.
Bob Aman
So, the `str( BlobKey.key() )` values won't be the same. So there isn't any way to access that _already cached_ sha-1 that GAE seems to already have computed for each image?
bobobobo
+2  A: 

Currently it is not possible to get the hash of the content of a blob stored in AppEngine's blobstore without using an external script to download it and hash it (a far from ideal solution).

Attaching a star to issue 2510 on the AppEngine issue tracker may help get the ability to hash blobs into AppEngine.

Noah McIlraith