from datetime import timedelta from time import time from string import printable from random import randrange,sample from hashlib import md5,sha1 from os import getcwd from math import factorial from itertools import permutations from sys import stdin guess=guesspass=userchar=userpass=hidepass=arem=trem='' userlength=attempt=percent=timer=timerem=max=repetition=0 newline,tab,backspace,Backspace,cr,hidechar,pc,colon,hyphen,space,dot,comma,slash,backslash,second='\n','\t','\x7f','\b','\r','*','%',':','-',' ','.',',','/','\\','s' sep=slash if slash in getcwd()else backslash traceback,file,line1,line2,error1,error2,title,status,prompt,copyright,b,e,r,g,y,display,hashalgo,details,adjuster='Traceback (most recent call last)',lambda no:f'File "{getcwd()}{sep}{__file__}"{comma}{space}line{space}{no}{comma}{space}in <module>','from getch import getch',"with open('dictionary.txt')as file:",'ModuleNotFoundError','FileNotFoundError',f"{hidechar*14}{space}{space.join('PASSWORD')}{space*2}{space.join('CRACKER')}{space}{hidechar*14}",f"{hidechar*16}{space}{space.join('ACCESS')}{space*2}{space.join('GRANTED')}{space}{hidechar*16}",f'{newline*2}{tab}Please Enter Your Secret Password Here{space}{hyphen*2}>{space}',f"{newline*2}Copyright{space}©{space}{printable[2]}{printable[0]}{printable[2]}{printable[0]}{hyphen}{printable[2]}{printable[1]}{comma}{space}Abhrankan\'s{space}World{dot}{space}All Rights Reserved{dot}",'\033[1m','\033[0m','\033[91m','\033[92m','\033[93m',lambda var1,var2,no,lineno:f'{traceback}{colon}{newline}{space*4}{file(no)}{newline}{space*8}{lineno}{newline}{var1}{colon}{space}{var2}{newline}',lambda word,algo:algo(word.encode()).hexdigest(),lambda:f'{cr}{attempt}{space}{colon}{space}{adjuster(total,attemptrem)}{attemptrem}{space}{colon}{space}{total}{space}{colon}{space}{percent}{pc}{space}{colon}{space}{timer}{second}{space}{colon}{space}{adjuster(max,timerem)}{timerem}{second}{space}{colon}{space}{max}{second}{space}{colon}{space}{guess}',lambda tot,rem:'0'*(len(f'{tot}')-len(f'{rem}'))if len(f'{tot}')-len(f'{rem}')else '' try: from getch import getch def getpass(prompt=None): global userchar,userlength,userpass,hidepass print(end=prompt,flush=True) while userchar!=newline: userchar=getch() if userchar!=newline: if userchar!=backspace: userlength+=1 userpass+=userchar hidepass+=hidechar print(end=hidechar,flush=True) elif userlength>0: userlength-=1 userpass,hidepass=userpass[:userlength],hidepass[:userlength] print(end=f'{Backspace}{space}{Backspace}',flush=True) elif not userlength: userchar='' return userpass except eval(error1)as errno1: print(display(error1,errno1,14,line1)) from getpass import getpass print(f'{b}{y}{title}{r}{copyright}{g}{prompt}') userpass=stdin.readline() if not userlength and not hidepass: userlength=len(userpass) hidepass=hidechar*userlength userhashmd5,userhashsha1,guessed,base=hashalgo(userpass,md5),hashalgo(userpass,sha1),[],[] def checkpass(userpass=userpass,alnum=''): if userpass.isalnum(): if userpass.isalpha(): if userpass.islower(): guesspass=printable[10:36] elif userpass.isupper(): guesspass=printable[36:62] else: guesspass=printable[10:62] elif userpass.isdigit(): guesspass=printable[:10] elif userpass.islower(): guesspass=printable[:36] elif userpass.isupper(): guesspass=printable[:10]+printable[36:62] else: guesspass=printable[:62] elif userpass.isspace(): guesspass=printable[-6] else: for i in userpass: if i.isalnum(): alnum+=i if userpass!=alnum: guesspass=printable[62:-5] if alnum: guesspass+=checkpass(userpass=alnum,alnum='') return guesspass def Password_validator(guess,attempt,repetition,base): global start start,symbol,symbol_new,num_new=0,printable[62:-5],[],[] try: with open('dictionary.txt')as file: base,start=file.read().upper().split(newline)if userlength>2 and userpass.isalpha()else base,time()if userlength>2 and userpass.isalpha()else start except eval(error2)as errno2: print(display(error2,errno2,62,line2)) for i in userpass: if userpass.count(i)>1: repetition=1 break for i in base: if userhashmd5==hashalgo(i,md5)and userhashsha1==hashalgo(i,sha1): guess=i elif userhashmd5==hashalgo(i.lower(),md5)and userhashsha1==hashalgo(i.lower(),sha1): guess=i.lower() attempt+=1 elif userhashmd5==hashalgo(i.title(),md5)and userhashsha1==hashalgo(i.title(),sha1): guess=i.title() attempt+=2 else: attempt+=3 continue attempt+=1 break else: attempt=0 if userlength<7: return 'Your Password Must Contain Atleast 7 Characters!',guess,attempt,repetition,base for i in symbol: if i in userpass: symbol_new.append(i) count=len(symbol_new) if count<2: return 'Your Password Must Contain Atleast 2 Symbols!',guess,attempt,repetition,base for num in range(10): if f'{num}'in userpass: num_new.append(num) count_2=len(num_new) if count_2<2: return 'Your Password Must Contain Atleast 2 Numbers!',guess,attempt,repetition,base else: return 'Your Password Is Very Strong!',guess,attempt,repetition,base return 'Your Password Is Very Popular!',guess,attempt,repetition,base guesspass=checkpass() Password,guess,attempt,repetition,base=Password_validator(guess,attempt,repetition,base) attack='Dictionary'if guess else 'Brute-Force' guesslength,guesshashmd5,guesshashsha1=len(guesspass),hashalgo(guess,md5),hashalgo(guess,sha1) if guess: attemptrem=total=len(base)*3 elif repetition: attemptrem=total=guesslength**userlength if guesslength<userlength else guesslength**userlength-factorial(guesslength)//factorial(guesslength-userlength) for i in permutations(guesspass,userlength): guessletter='' for j in i: guessletter+=j guessed.append(guessletter) else: attemptrem=total=factorial(guesslength)//factorial(guesslength-userlength) print(f'{newline*2}{tab}{prompt[21:37]}Is{tab}{colon}{tab}{hidepass}{newline*2}{tab}{prompt[28:37]}Length Is{tab}{colon}{tab}{userlength}{newline*2}{tab}Information Density Is{tab}{colon}{tab}{guesslength}{newline*2}{tab}How Secure Is Your Password?{newline*2}{tab}{Password}{newline*2}M{dot}D{hyphen}{printable[5]}{space}Hash Is{tab}{colon}{tab}{userhashmd5}{newline*2}SHA{hyphen}{printable[1]}{space}Hash Is{tab}{colon}{space*3}{userhashsha1}{newline*2}{tab}Executing The{space}{attack}{space}Attack Algorithm{(space+dot)*3}{newline}') if not start: start=time() while guesshashmd5!=userhashmd5 or guesshashsha1!=userhashsha1: if repetition: guess='' for letter in range(userlength): guess+=guesspass[randrange(guesslength)] else: guess=''.join(sample(guesspass,userlength)) if guess not in guessed: attempt+=1 attemptrem-=1 percent,end=round(attempt*100/total),time() timer=round(end-start) max=round(timer*total/attempt) timerem=max-timer print(end=details(),flush=True) guessed.append(guess) guesshashmd5,guesshashsha1=hashalgo(guess,md5),hashalgo(guess,sha1) print(newline)if hyphen in attack else '' percent,end=attempt*10**5//total/1000,time() timer=timedelta(seconds=end-start) max,min=timedelta(seconds=(end-start)*total/attempt),timedelta(seconds=(end-start)/attempt) avg,pace=timedelta(seconds=(end-start)*(total+1)/attempt/2),round(attempt/(end-start)) def print_text_in_symbol(text_input, inline, symbol_char, symbol_bg): a = ['000000000000', '000111111000', '011000000110', '011000000110', '011111111110', '011000000110', '011000000110', '011000000110'] b = ['000000000000', '011111111000', '011000000110', '011000000110', '011111111000', '011000000110', '011000000110', '011111111000'] c = ['000000000000', '000111111000', '011000000110', '011000000000', '011000000000', '011000000000', '011000000110', '000111111000'] d = ['000000000000', '011111111000', '011000000110', '011000000110', '011000000110', '011000000110', '011000000110', '011111111000'] e = ['000000000000', '011111111110', '011000000000', '011000000000', '011111111100', '011000000000', '011000000000', '011111111110'] f = ['000000000000', '011111111110', '011000000000', '011000000000', '011111111100', '011000000000', '011000000000', '011000000000'] g = ['000000000000', '000111111000', '011000000110', '011000000000', '011000000000', '011000011110', '011000000110', '000111111000'] h = ['000000000000', '011000000110', '011000000110', '011000000110', '011111111110', '011000000110', '011000000110', '011000000110'] i = ['000000000000', '000111111000', '000001100000', '000001100000', '000001100000', '000001100000', '000001100000', '000111111000'] j = ['000000000000', '000001111110', '000000011000', '000000011000', '000000011000', '000000011000', '011000011000', '000111100000'] k = ['000000000000', '011000000110', '011000011000', '011001100000', '011110000000', '011001100000', '011000011000', '011000000110'] l = ['000000000000', '011000000000', '011000000000', '011000000000', '011000000000', '011000000000', '011000000000', '011111111110'] m = ['000000000000', '011000000110', '011110011110', '011001100110', '011001100110', '011000000110', '011000000110', '011000000110'] n = ['000000000000', '011000000110', '011000000110', '011110000110', '011001100110', '011000011110', '011000000110', '011000000110'] o = ['000000000000', '000111111000', '011000000110', '011000000110', '011000000110', '011000000110', '011000000110', '000111111000'] p = ['000000000000', '011111111000', '011000000110', '011000000110', '011111111000', '011000000000', '011000000000', '011000000000'] q = ['000000000000', '000111111000', '011000000110', '011000000110', '011000000110', '011001100110', '011000011000', '000111100110'] r = ['000000000000', '011111111000', '011000000110', '011000000110', '011111111000', '011001100000', '011000011000', '011000000110'] s = ['000000000000', '000111111110', '011000000000', '011000000000', '000111111000', '000000000110', '000000000110', '011111111000'] t = ['000000000000', '011111111110', '000001100000', '000001100000', '000001100000', '000001100000', '000001100000', '000001100000'] u = ['000000000000', '011000000110', '011000000110', '011000000110', '011000000110', '011000000110', '011000000110', '000111111000'] v = ['000000000000', '011000000110', '011000000110', '011000000110', '011000000110', '000110011000', '000110011000', '000001100000'] w = ['000000000000', '011000000110', '011000000110', '011000000110', '011001100110', '011001100110', '011001100110', '000110011000'] x = ['000000000000', '011000000110', '011000000110', '000110011000', '000001100000', '000110011000', '011000000110', '011000000110'] y = ['000000000000', '011000000110', '011000000110', '000110011000', '000001100000', '000001100000', '000001100000', '000001100000'] z = ['000000000000', '011111111110', '000000000110', '000000011000', '000001100000', '000110000000', '011000000000', '011111111110'] sp = ['000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000000000000'] n0 = ['000000000000', '000111111000', '011000000110', '011000011110', '011001100110', '011110000110', '011000000110', '000111111000'] n1 = ['000000000000', '000001100000', '000111100000', '000001100000', '000001100000', '000001100000', '000001100000', '000111111000'] n2 = ['000000000000', '000111111000', '011000000110', '000000000110', '000000011000', '000001100000', '000110000000', '011111111110'] n3 = ['000000000000', '011111111110', '000000011000', '000001100000', '000000011000', '000000000110', '011000000110', '000111111000'] n4 = ['000000000000', '000000011000', '000001111000', '000110011000', '011000011000', '011111111110', '000000011000', '000000011000'] n5 = ['000000000000', '011111111110', '011000000000', '011111111000', '000000000110', '000000000110', '011000000110', '000111111000'] n6 = ['000000000000', '000001111000', '000110000000', '011000000000', '011111111000', '011000000110', '011000000110', '000111111000'] n7 = ['000000000000', '011111111110', '000000000110', '000000011000', '000001100000', '000110000000', '000110000000', '000110000000'] n8 = ['000000000000', '000111111000', '011000000110', '011000000110', '000111111000', '011000000110', '011000000110', '000111111000'] n9 = ['000000000000', '000111111000', '011000000110', '011000000110', '000111111110', '000000000110', '000000011000', '000111100000'] s0 = ['000000000000', '000111111000', '011000000110', '000000000110', '000000011000', '000001100000', '000000000000', '000001100000'] s1 = ['000000000000', '000001100000', '000001100000', '000001100000', '000001100000', '000001100000', '000000000000', '000001100000'] s2 = ['000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000001100000', '000001100000'] s3 = ['000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000000000000', '000001100000'] s4 = ['000000000000', '000000000000', '000000000000', '000000000000', '001111111100', '000000000000', '000000000000', '000000000000'] s5 = ['000000000000', '000000000000', '000001100000', '000001100000', '011111111110', '000001100000', '000001100000', '000000000000'] ascii_alph = [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, sp, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9,s0, s1, s2, s3, s4, s5, s5] res = '' alph = 'abcdefghijklmnopqrstuvwxyz 0123456789?!,.-+' text_input = text_input if text_input else 'none' try: for char in text_input: alph.index(char) except ValueError: text_input = 'error' finally: inline = False if len(text_input) > 5 else inline if inline: print_res = '' for i in range(8): for char in text_input: ch_ascii = ascii_alph[alph.index(char)] res += ch_ascii[i] res += newline for char in res: if char == '0': print_res += symbol_bg elif char == '1': print_res += symbol_char else: print_res += newline print(print_res) else: for char in text_input: ch_ascii = ascii_alph[alph.index(char)] for i in ch_ascii: for t in i: for char in t: if char == '0': res += symbol_bg elif char == '1': res += symbol_char print(res) res = '' print() ch = 'XO#@' ch_bg = '\'`,.' rand_ch = ch[randrange(len(ch))] rand_bg = ch_bg[randrange(len(ch_bg))] print_text_in_symbol(guess.lower(), True, rand_ch, rand_bg) print(f'{y}{status}{r}{copyright}{g}{newline*2}{tab}{prompt[16:20]}{prompt[27:37]}Is{tab}{colon}{tab}{guess}{newline*2}{tab}No{dot}{space}Of Attempts Is{tab}{colon}{tab}{attempt}{newline*2}{tab}No{dot}{space}Of Combinations Is{tab}{colon}{tab}{total}{newline*2}{tab}Percent Of Attempts Is{tab}{colon}{tab}{percent}{pc}{newline*2}{tab}Took A Total Time Of{tab}{colon}{tab}{timer}{newline*2}{tab}Takes A Max{dot}{space}Time Of{tab}{colon}{tab}{max}{newline*2}{tab}Takes A Min{dot}{space}Time Of{tab}{colon}{tab}{min}{newline*2}{tab}Takes An Avg{dot}{space}Time Of{tab}{colon}{tab}{avg}{newline*2}{tab}Attempts Per Second Is{tab}{colon}{tab}{pace}')
Write, Run & Share Python code online using OneCompiler's Python online compiler for free. It's one of the robust, feature-rich online compilers for python language, supporting both the versions which are Python 3 and Python 2.7. Getting started with the OneCompiler's Python editor is easy and fast. The editor shows sample boilerplate code when you choose language as Python or Python2 and start coding.
OneCompiler's python online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample python program which takes name as input and print your name with hello.
import sys
name = sys.stdin.readline()
print("Hello "+ name)
Python is a very popular general-purpose programming language which was created by Guido van Rossum, and released in 1991. It is very popular for web development and you can build almost anything like mobile apps, web apps, tools, data analytics, machine learning etc. It is designed to be simple and easy like english language. It's is highly productive and efficient making it a very popular language.
When ever you want to perform a set of operations based on a condition IF-ELSE is used.
if conditional-expression
#code
elif conditional-expression
#code
else:
#code
Indentation is very important in Python, make sure the indentation is followed correctly
For loop is used to iterate over arrays(list, tuple, set, dictionary) or strings.
mylist=("Iphone","Pixel","Samsung")
for i in mylist:
print(i)
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while condition
#code
There are four types of collections in Python.
List is a collection which is ordered and can be changed. Lists are specified in square brackets.
mylist=["iPhone","Pixel","Samsung"]
print(mylist)
Tuple is a collection which is ordered and can not be changed. Tuples are specified in round brackets.
myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
Below throws an error if you assign another value to tuple again.
myTuple=("iPhone","Pixel","Samsung")
print(myTuple)
myTuple[1]="onePlus"
print(myTuple)
Set is a collection which is unordered and unindexed. Sets are specified in curly brackets.
myset = {"iPhone","Pixel","Samsung"}
print(myset)
Dictionary is a collection of key value pairs which is unordered, can be changed, and indexed. They are written in curly brackets with key - value pairs.
mydict = {
"brand" :"iPhone",
"model": "iPhone 11"
}
print(mydict)
Following are the libraries supported by OneCompiler's Python compiler
Name | Description |
---|---|
NumPy | NumPy python library helps users to work on arrays with ease |
SciPy | SciPy is a scientific computation library which depends on NumPy for convenient and fast N-dimensional array manipulation |
SKLearn/Scikit-learn | Scikit-learn or Scikit-learn is the most useful library for machine learning in Python |
Pandas | Pandas is the most efficient Python library for data manipulation and analysis |
DOcplex | DOcplex is IBM Decision Optimization CPLEX Modeling for Python, is a library composed of Mathematical Programming Modeling and Constraint Programming Modeling |