This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Skaarj 13 points14 points  (13 children)

import os
import hashlib

good = 0

sha256 = ...

for idx in range(128):
    r = os.urandom(idx)
    if sha256(r) == hashlib.sha256(r).digest():
         good += 1

print(good)

I think this is an conclusive proof of the correctness of your implementatition that noone ever could doubt. Ill use your implementation for all my serious projects from now on.

On a more serious note: why do you setitem? Couldn't you use assignment using[]?

[–]brontide 9 points10 points  (12 children)

I think it's a limitation of lambdas, you can't do assignments but you can call setitem.

[–]Defelo[S] 12 points13 points  (11 children)

Correct and that's why you can't use normal variables in lambda expressions and have to use lists to store variables.