Skip to content

NagubandiAlekhya/Password-Strength-Checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Password-Strength-Checker

#Importing the Libraries

import pandas as pd

import numpy as np

from sklearn.feature_extraction.text import CountVectorizer

from sklearn.feature_extraction.text import TfidfVectorizer

from sklearn.model_selection import train_test_split

from sklearn.ensemble import RandomForestClassifier

#Reading the Dataset

data = pd.read_csv("data.csv", error_bad_lines=False)

print(data.head())

data = data.dropna()

data["strength"] = data["strength"].map({0: "Weak", 1: "Medium", 2: "Strong"})

print(data.sample(5))

def word(password):

character=[]

for i in password:

    character.append(i)
    
return character

x = np.array(data["password"])

y = np.array(data["strength"])

tdif = TfidfVectorizer(tokenizer=word)

x = tdif.fit_transform(x)

#Splitting the dataset into training and testing sets

xtrain, xtest, ytrain, ytest = train_test_split(x,y,test_size=0.05,random_state=27)

model = RandomForestClassifier()

model.fit(xtrain, ytrain)

print(model.score(xtest, ytest))

import getpass

user = getpass.getpass("Enter Password: ")

data = tdif.transform([user]).toarray()

output = model.predict(data)

print(output)

#OUTPUT:

Enter Password: ········

['Strong']