Skip to content

Instantly share code, notes, and snippets.

@mattbillenstein
Last active November 19, 2017 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbillenstein/39f0399e842c63355c74173e34d49965 to your computer and use it in GitHub Desktop.
Save mattbillenstein/39f0399e842c63355c74173e34d49965 to your computer and use it in GitHub Desktop.
import time
find = '07123E1F482356C415F684407A3B8723E10B2CBBC0B8FCD6282C49D37C9C1ABC'
length = len(find)
# dd if=/dev/urandom of=200mb.txt bs=1000000 count=200
# echo '07123E1F482356C415F684407A3B8723E10B2CBBC0B8FCD6282C49D37C9C1ABC' >> 200mb.txt
data = open('200mb.txt').read()
found = 0
start = time.time()
i = 0
for i in xrange(len(data)):
if data[i] == find[found]:
found += 1
else:
found = 0
if found == length:
print 'found at ', i
found = 0
print 'scan took', time.time() - start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment