hash

Efficiently saving a file by hash in Django

无人久伴 提交于 2021-01-21 09:06:11
问题 I am working on a Django project. What I want the user to be able to do is upload a file (through a Form) and then save the file locally to a custom path and with a custom filename - its hash. The only solution I can think of is by using the "upload_to" argument of the FileField I'm using. What this translates to (I think): 1) Write the file to disk 2) Calculate hash 3) Return path + hash as filename The problem is that there are two write operations: one when saving the file from memory to

Is it possible to use the GPU to accelerate hashing in Python?

扶醉桌前 提交于 2021-01-21 04:02:38
问题 I recently read Jeff's blog post entitled Speed Hashing, where amongst other things he mentions that you can hash things really fast by harnessing the power of your GPU. I was wondering whether or not it was possible to harness the power of the GPU to hash things in Python (md5, sha-1 etc)? I'm interested in this for trying to see how fast I can brute-force things (not real world stuff, from old leaked data dumps). At the moment, I'm doing this sort of thing (simplified example): from

Is it possible to use the GPU to accelerate hashing in Python?

ε祈祈猫儿з 提交于 2021-01-21 04:01:14
问题 I recently read Jeff's blog post entitled Speed Hashing, where amongst other things he mentions that you can hash things really fast by harnessing the power of your GPU. I was wondering whether or not it was possible to harness the power of the GPU to hash things in Python (md5, sha-1 etc)? I'm interested in this for trying to see how fast I can brute-force things (not real world stuff, from old leaked data dumps). At the moment, I'm doing this sort of thing (simplified example): from

Generate custom length hash values of a String in Swift

笑着哭i 提交于 2021-01-04 07:26:30
问题 Is it possible to somehow "hash" a given String with length n to a hash value of an arbitrary length m? I want to achieve something like follows: let s1 = "<UNIQUE_USER_IDENTIFIER_1>" let s2 = "<UNIQUE_USER_IDENTIFIER_2>" let x1 = s1.hashValue(length: 4) let x2 = s2.hashValue(length: 4) I want to assign each given user a (e.g. four-digit) number, that is based on its unique UID. Is that possible? 回答1: First, I want to be clear that you mean "hash" and don't mean "(lossless) compress." You

Why digests are different depend on registry?

泄露秘密 提交于 2021-01-01 04:21:52
问题 AFAIK, image digest is a hash of image's manifest body. When I pull busybox image from docker hub, and push it to my private registry, the digests get different. $ docker pull busybox ... Digest: sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4 Status: Downloaded newer image for busybox:latest $ docker tag busybox myregistry/busybox $ docker push myregistry/busybox ... 08c2295a7fa5: Pushed latest: digest: sha256

Why digests are different depend on registry?

こ雲淡風輕ζ 提交于 2021-01-01 04:20:34
问题 AFAIK, image digest is a hash of image's manifest body. When I pull busybox image from docker hub, and push it to my private registry, the digests get different. $ docker pull busybox ... Digest: sha256:2605a2c4875ce5eb27a9f7403263190cd1af31e48a2044d400320548356251c4 Status: Downloaded newer image for busybox:latest $ docker tag busybox myregistry/busybox $ docker push myregistry/busybox ... 08c2295a7fa5: Pushed latest: digest: sha256

How do I specify a custom hash function explicitly for unordered_set by passing a named function?

我与影子孤独终老i 提交于 2020-12-30 12:07:14
问题 Based on the accepted answer to this question, one can use a specialization to std to provide a hash function for a user defined type. #include <unordered_set> #include <stdint.h> struct FooBar { int i; }; namespace std { template <> struct hash<FooBar> { size_t operator()(const FooBar & x) const { return x.i; } }; } int main(){ std::unordered_set<FooBar> foo(0); } However, the documentation seems to imply that a custom hash function can also be passed explicitly into the constructor, and I

How do I specify a custom hash function explicitly for unordered_set by passing a named function?

五迷三道 提交于 2020-12-30 11:54:47
问题 Based on the accepted answer to this question, one can use a specialization to std to provide a hash function for a user defined type. #include <unordered_set> #include <stdint.h> struct FooBar { int i; }; namespace std { template <> struct hash<FooBar> { size_t operator()(const FooBar & x) const { return x.i; } }; } int main(){ std::unordered_set<FooBar> foo(0); } However, the documentation seems to imply that a custom hash function can also be passed explicitly into the constructor, and I

Time complexity of MD5

爷,独闯天下 提交于 2020-12-30 09:55:37
问题 What is the time complexity of the MD5 algorithm? I couldn't find a definitive answer online. I think the complexity is O(n) but I'm not really sure. 回答1: O(n) as mentioned by DuBuisson and osgx in the comments. 来源: https://stackoverflow.com/questions/43625569/time-complexity-of-md5

creating unordered_set with lambda

点点圈 提交于 2020-12-29 10:12:34
问题 How can I make unordered_set with lambda? (I know how to make it with user defined hash struct and operator== ) My current code is : #include <unordered_set> #include <functional> struct Point { float x; float y; Point() : x(0), y(0) {} }; int main() { auto hash=[](const Point& pt){ return (size_t)(pt.x*100 + pt.y); }; auto hashFunc=[&hash](){ return std::function<size_t(const Point&)> (hash); }; auto equal=[](const Point& pt1, const Point& pt2){ return ((pt1.x == pt2.x) && (pt1.y == pt2.y));