You are viewing a single comment's thread.

view the rest of the comments →

TheSoaringShite ago

no way to reverse this encryption.

How long does it take to iterate the lot? @Atko

CptCmdrAwesome ago

About 0.6 seconds for a class B on a single core using standard Python, for me. So if I haven't miscalculated or otherwise screwed up, about 10 hours for the whole IPv4 range.

import hashlib
from base64 import b64encode
def undotIPv4 (dotted):
    return sum (int (octet) << ( (3 - i) << 3) for i, octet in enumerate (dotted.split ('.') ) )
def dotIPv4 (addr):
    return '.'.join (str (addr >> off & 0xff) for off in (24, 16, 8, 0) )
def rangeIPv4 (start, stop):
    for addr in range (undotIPv4 (start), undotIPv4 (stop) ):
        yield dotIPv4 (addr)
count = 0
for x in rangeIPv4 ('1.1.0.0', '1.1.255.255'):
    count += 1
    print b64encode(hashlib.sha512(x).digest())
print "Total IPs hashed: " + str(count)

time python voathash.py > /dev/null

real 0m0.607s user 0m0.505s sys 0m0.047s

TheSoaringShite ago

I got under four hours, but I just hashed the numbers 0 to 222 in superior perl. (I think you got a good chunk of start-up time there)

I also posted it on /v/voatdev: https://voat.co/v/voatdev/comments/413694

CptCmdrAwesome ago

Yeah I'd agree with what you say about the startup time, plus I was on a VM. FYI from what I can tell, the Voat code does hash a string rather than a number.

Not sure I agree with the use of a certain word in your comment though. I suppose I could have written it in Perl, but I wanted other people to be able to read it, and I didn't want my screen to look like I sneezed on it ;P

Cheers :)