Package magma :: Package magma :: Module sha1_gnutella
[hide private]
[frames] | no frames]

Module sha1_gnutella

source code

Sha1 Gnutella - Readout files and calculate the sha1-hashes. Output them base32 encoded.

Usage:

Output: <sha1-hash1> <filename1> <sha1-hash2> <filename2>

Functions [hide private]
 
sha1_gnutella(filepath, fragment_size=10485760)
Calculate the sha1 hash and output it base32 encoded as is required by magnet links.
source code
 
test_speed(files, min=1048576, max=15728640, step=1048576)
Test different settings of the fragment_size.
source code
 
help()
Display the usage information.
source code
Variables [hide private]
  __depends__ = 'hashlib, base64'
  FILE_FRAGMENT_SIZE_BYTES = 10485760
The length of the segments to read in one go.
  filepath = 'sha1_gnutella.py'
Function Details [hide private]

sha1_gnutella(filepath, fragment_size=10485760)

source code 

Calculate the sha1 hash and output it base32 encoded as is required by magnet links.

Parameters:
  • filepath (String) - The path to the file to hash. Must be a file! This function is too low level to add recursion into subdirectories.
  • fragment_size (Int) - Length of the fragment to read in bytes.
Returns:
The sha1 hash, base32 encoded (String).

test_speed(files, min=1048576, max=15728640, step=1048576)

source code 

Test different settings of the fragment_size.

Result: The fragment_size is almost irrelevant. Anything between 512kiB and 10MiB offers about the same speed.

Parameters:
  • files (List) - The files to hash.
Returns:
None