Skip to main content

Posts

Showing posts with the label Python

Things you should know in Python right now

  timeit The  timeit  module in Python provides a simple way to measure the execution time of small bits of Python code. It offers both a command-line interface and a callable one. from timeit import default_timer as timer : This line imports the  default_timer  function from the  timeit  module and renames it to  timer . start = timer() : This line gets the current time using the  timer  function and stores it in the  start  variable. a = 'a' * 6 : This line creates a string variable  a  that contains six 'a' characters. stop = timer() : This line gets the current time again using the  timer  function and stores it in the  stop  variable. print(stop - start) : This line calculates the difference between the start and stop times (i.e., the time it took to execute the code between the  start  and  stop  lines) and prints it to the console. The output of the code will be the time ...

Breaking SHA-1 Hashes with Python: A Beginner’s Guide to Hash Cracking

  GitHub:   https://github.com/AdithyakrishnaV/Python-for-Penetration-Testing/blob/master/SHA-1_PASSWORD_CRACKER.py hashing is a one-way function. So we cannot reverse the hash we can only Brute-force it and check for a similar hash import hashlib This line imports the  hashlib  library, which provides implementations of various hash functions. def hashing ( check,word ): This line defines a function called  hashing  that takes two parameters:  check  and  word for w in word: This line sets up a loop that iterates over each word in the  word  list. hasher =hashlib.sha1(w.encode()) This line uses the SHA1 algorithm from the  hashlib  library to hash the current  w  word in the loop. It first encodes the word as bytes using the  encode()  method. c =hasher.hexdigest() This line extracts the resulting hash from the  hasher  object and converts it to a string of hexadecimal digits using the...