Skip to content

Commit

Permalink
Secure Source of Randomness
Browse files Browse the repository at this point in the history
  • Loading branch information
pixeebot[bot] authored Jan 25, 2025
1 parent 0f03acb commit 4fe3472
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions introduction/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
import logging
import os
import pickle
import random
import re
import string
import subprocess
import uuid
from dataclasses import dataclass
from hashlib import md5
from io import BytesIO
from random import randint
from xml.dom.pulldom import START_ELEMENT, parseString
from xml.sax import make_parser
from xml.sax.handler import feature_external_ges
Expand All @@ -38,6 +36,7 @@
from .models import (FAANG, AF_admin, AF_session_id, Blogs, CF_user, authLogin,
comments, info, login, otp, sql_lab_table, tickits)
from .utility import customHash, filter_blog
import secrets

#*****************************************Lab Requirements****************************************************#

Expand Down Expand Up @@ -486,7 +485,7 @@ def login_otp(request):
def Otp(request):
if request.method=="GET":
email=request.GET.get('email')
otpN=randint(100,999)
otpN=secrets.SystemRandom().randint(100,999)
if email and otpN:
if email=="admin@pygoat.com":
otp.objects.filter(id=2).update(otp=otpN)
Expand Down Expand Up @@ -670,7 +669,7 @@ def a10_lab2(request):
#*********************************************************A11*************************************************#

def gentckt():
return (''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase, k=10)))
return (''.join(secrets.SystemRandom().choices(string.ascii_uppercase + string.ascii_lowercase, k=10)))

def insec_desgine(request):
if request.user.is_authenticated:
Expand Down

0 comments on commit 4fe3472

Please sign in to comment.