Skip to main content
Code Review

Return to Question

Tweeted twitter.com/StackCodeReview/status/1314490808410742784
edited title
Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141

Brute Force generator (Python 3)

Became Hot Network Question
deleted 247 characters in body; edited title
Source Link
Sandra
  • 121
  • 1
  • 4

Brute Force generator not running infinitely (Python 3)

I just wrote a little Python 3 program to spit out every possible combination of a set of 99 characters. It gets the job done, but it turned outI would be very repetitive and is not running infinitely, but only up to 10-digit-combinationsinterested in what you think of it.

I am just a few days into Python, so I would be grateful for even seemingly obvious advice.

I read about importable functions from "itertools" specifically designed for brute forcing, but I would like to build a little more from scratch, to better understand the logic behind it just now.

Brute Force generator not running infinitely (Python 3)

I just wrote a little Python 3 program to spit out every possible combination of a set of 99 characters. It gets the job done, but it turned out very repetitive and is not running infinitely, but only up to 10-digit-combinations.

I am just a few days into Python, so I would be grateful for even seemingly obvious advice.

I read about importable functions from "itertools" specifically designed for brute forcing, but I would like to build a little more from scratch, to better understand the logic behind it just now.

Brute Force generator (Python 3)

I just wrote a little Python 3 program to spit out every possible combination of a set of 99 characters. It gets the job done, but I would be very interested in what you think of it.

I am just a few days into Python, so I would be grateful for even seemingly obvious advice.

Source Link
Sandra
  • 121
  • 1
  • 4

Brute Force generator not running infinitely (Python 3)

I just wrote a little Python 3 program to spit out every possible combination of a set of 99 characters. It gets the job done, but it turned out very repetitive and is not running infinitely, but only up to 10-digit-combinations.

I am just a few days into Python, so I would be grateful for even seemingly obvious advice.

I read about importable functions from "itertools" specifically designed for brute forcing, but I would like to build a little more from scratch, to better understand the logic behind it just now.


import sys
# List of 99 characters and a blank string:
lib=["","0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","°","!","\"","§","$","%","&","/","(",")","=","ß"," ́","`","+","#","-",".",",",">","<","@","€","|","^","~","–","{","[","]","}","Ä","Ö","Ü","ä","ö","ü"]
# 10 counters for up to 10-digit-combinations:
counter0=-1
counter1=0
counter2=0
counter3=0
counter4=0
counter5=0
counter6=0
counter7=0
counter8=0
counter9=0
# Repetitive if-statements adding to the counters:
for i in range(sys.maxsize**99999):
 counter0+=1
 
 if counter0>99:
 counter0=counter0*0
 counter1+=1
 
 elif counter1>99:
 counter1=counter1*0
 counter2+=1
 
 elif counter2>99:
 counter2=counter2*0
 counter3+=1
 
 elif counter3>99:
 counter3=counter3*0
 counter4+=1
 
 elif counter4>99:
 counter4=counter4*0
 counter5+=1
 
 elif counter5>99:
 counter5=counter5*0
 counter6+=1
 
 elif counter6>99:
 counter6=counter6*0
 counter7+=1
 
 elif counter7>99:
 counter7=counter7*0
 counter8+=1
 
 elif counter8>99:
 counter8=counter8*0
 counter9+=1
 
 elif counter9>99:
 print("DONE.")
 
# Printing the translation from counters to character - and deleting the former output so it stays in one line:
 
 else:
 print(lib[counter0]+lib[counter1]+lib[counter2]+lib[counter3]+lib[counter4]+lib[counter5]+lib[counter6]+lib[counter7]+lib[counter8]+lib[counter9], end="\r")
 sys.stdout.write("\b"*10+" "*10+"\b"*10)
lang-py

AltStyle によって変換されたページ (->オリジナル) /