Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.
- def caeser(text,mode,key):
- res=""
- for i in text:
- if i.islower():
- if mode=="encrypt":
- res+=chr((ord(i)+key-97)%26+97)
- else:
- res+=chr((ord(i)-key-97)%26+97)
- elif i.isupper():
- if mode=="encrypt":
- res+=chr((ord(i)+key-65)%26+65)
- else:
- res+=chr((ord(i)-key-65)%26+65)
- else:
- res+=i
- return res
- print(caeser("KHOOR zruog","decrypt",3))
- 2.
- def encrypt(text,rails):
- text=text.replace(" ","").upper()
- fence=[[] for i in range(rails)]
- rail=0
- step=1
- for i in text:
- fence[rail].append(i)
- rail+=step
- if rail==0 or rail==rails-1:
- step*=-1
- cipher=""
- for i in fence:
- cipher+="".join(i)
- print(cipher)
- encrypt("geeks for geeks",3)
- def decrypt(cipher,rails):
- fence=[[""]*len(cipher) for i in range(rails)]
- rail=0
- step=1
- for i in range(len(cipher)):
- fence[rail][i]="*"
- rail+=step
- if rail==0 or rail==rails-1:
- step*=-1
- k=0
- for i in range(rails):
- for j in range(len(cipher)):
- if fence[i][j]=="*":
- fence[i][j]=cipher[k];k+=1
- text=""
- rail=0
- step=1
- for i in range(len(cipher)):
- text+=fence[rail][i]
- rail+=step
- if rail==0 or rail==rails-1:
- step*=-1
- print(text)
- decrypt("GSGSEKFREKEOE",3)
- 3.
- import hashlib
- def hashing(password):
- sha=hashlib.sha256()
- enco=password.encode("utf-8")
- sha.update(enco)
- return sha.hexdigest()
- print((hashing("")))
- 4.
- import hashlib
- import requests
- def check_pwned(password):
- hash_pass=hashlib.sha1(password.encode("utf-8")).hexdigest().upper()
- prefix=hash_pass[:5]
- suffix=hash_pass[5:]
- url=f"https://api.pwnedpasswords.com/range/{prefix}"
- response=requests.get(url)
- if response.status_code!=200:
- return -1
- hash=response.text.splitlines()
- for i in hash:
- suffiix,count=i.split(":")
- if suffix==suffiix:
- return int(count)
- f=open("meri.txt")
- for i in f:
- l=i.strip()
- username,password=l.split(",")
- c=check_pwned(password)
- if c<0:
- print("api error")
- elif c>0:
- print("pass found ",c)
- else:
- print("pass not found")
- For this if required
- pip install requests
- meri.txt file content format-,
- username1,password1
- username2,password2
- 5.
- import random
- f=open("diction.txt")
- w=f.readlines()
- for i in range(len(w)):
- w[i]=w[i].strip("\t\n")
- rlist=random.sample(w,3)
- print("".join(rlist))
- f.close()
- diction.txt
- mountain
- silent
- climb
- journey
- ocean
- brilliant
- whisper
- inspire
- shadow
- emerald
- discover
- courage
- wizard
- hidden
- wander
- triumph
- rocket
- 6.
- import itertools
- import string
- password = "dogyy" # the target password (small for demo)
- chars = string.ascii_lowercase # allowed characters: a–z
- attempts = 0
- for length in range(1, 6): # try length 1 to 5
- for combo in itertools.product(chars, repeat=length):
- attempts += 1
- guess = "".join(combo)
- if guess == password:
- print("Password found:", guess)
- print("Attempts:", attempts)
- exit()
- print("Password not found")
Advertisement
Add Comment
Please, Sign In to add comment