如何让我的程序返回密码强度(How can i get my program to return the password strength)

我正在努力使用我的密码评估程序。 我怎样才能确保当我插入密码时,我的程序会返回密码强度。 当我运行这个程序时,它说password_strength存储在.....)是我在程序结束时调用的返回错误吗?

print ("Welcome to this password rater program")
print ("Your password needs to have a minimum of 6 characters with a maximum of 20 characters.")
print ("Your password can contain lowercase and uppercase characters, numbers and special characters")
print("")


password = input("Please insert your password: ")


def check_len(password):
    l = len(password)
    if 6 < l < 20:
        x = check_char(password, l)
    else:
        x =  0
    return x


def check_char(password, l):
    for i in range(l):
        ascii = ord(password[i])
        num = 0                                
        upper = 0                               
        symbols = 0
        lower = 0
        space = 0

        if  96 < ascii < 123:      
            lower = 15
        elif 47 < ascii < 58:     
            num = 25
        elif 64 < ascii < 91:     
            upper = 25
        elif ascii == 32:
            space = 30
        else:                               
            symbols = 25
        total = ((lower + num + upper + space + symbols) * len(password))
    return total


def password_strength(total):
    if total >= 1000:
        print("Your chosen password is Very strong")
    elif 700 < total < 999:
        print("Your chosen password is strong")
    elif 500 < total < 699:
        print("your chosen password is medium")
    elif total <= 500:
        print("Your chosen password is weak")
    return total


strength = check_len(password)
print(password_strength(strength))

I'm struggling with my password rater program. How can i make sure that when i insert a password, my program returns the password strength. When i run this program it says that password_strength is stored at .....) is the return that i call at the end of my program wrong?

print ("Welcome to this password rater program")
print ("Your password needs to have a minimum of 6 characters with a maximum of 20 characters.")
print ("Your password can contain lowercase and uppercase characters, numbers and special characters")
print("")


password = input("Please insert your password: ")


def check_len(password):
    l = len(password)
    if 6 < l < 20:
        x = check_char(password, l)
    else:
        x =  0
    return x


def check_char(password, l):
    for i in range(l):
        ascii = ord(password[i])
        num = 0                                
        upper = 0                               
        symbols = 0
        lower = 0
        space = 0

        if  96 < ascii < 123:      
            lower = 15
        elif 47 < ascii < 58:     
            num = 25
        elif 64 < ascii < 91:     
            upper = 25
        elif ascii == 32:
            space = 30
        else:                               
            symbols = 25
        total = ((lower + num + upper + space + symbols) * len(password))
    return total


def password_strength(total):
    if total >= 1000:
        print("Your chosen password is Very strong")
    elif 700 < total < 999:
        print("Your chosen password is strong")
    elif 500 < total < 699:
        print("your chosen password is medium")
    elif total <= 500:
        print("Your chosen password is weak")
    return total


strength = check_len(password)
print(password_strength(strength))

原文:https://stackoverflow.com/questions/39913740
2021-12-22 16:12

满意答案

我的同事解决了我的问题,我希望这会有助于其他人!

https://github.com/LukeMason/angular-img-editor


My colleague solved my problem and I hope this will help others!

https://github.com/LukeMason/angular-img-editor

相关问答

更多

我应该如何使用jcrop在客户端裁剪图像并上传它?(How should I crop the image at client side using jcrop and upload it?)

Seahorsepip的回答非常棒。 我在非备用答案上做了很多改进。 http://jsfiddle.net/w1Lh4w2t/ 我会建议不要做那种奇怪的隐藏png的东西,当一个Image对象工作的时候也一样(只要我们不支持后备)。 var jcrop_api; var canvas; var context; var image; var prefsize; 尽管如此,尽管如此,最好还是将最终的数据从画布中提取出来,然后放在该字段中。 function loadImage(input) { ...

使用jQuery jcrop插件从网络摄像头上传照片是错误的大小。(Using jQuery jcrop plugin to upload photo from webcam is wrong size.?)

该代码是否正是您尝试使用的代码? 我的猜测是你有一个仍然是默认大小的画布(恰好是300x150),这导致它是发送到你的服务器并保存的图像。 另外,为什么预览的样式宽度和高度不是设置实际的宽度和高度? Is that code exactly what you are trying to use? My guess would be you have a canvas which is still at the default size (which just happens to be 300x1...

DotNetNuke中的JQuery + JCrop问题(JQuery + JCrop issue in DotNetNuke)

要从DotNetNuke引用jQuery,请调用DotNetNuke.Framework.jQuery.RequestRegistration() 。 这将使用共享的jQuery引用(以便jQuery在页面上只有一次,在<head/> ,无论有多少扩展要求它)。 如果您使用的是jQuery 6.1,则应使用客户端资源管理API来请求其他脚本,如下所示: <%@ Register TagPrefix="dnn" Namespace="DotNetNuke.Web.Client.ClientResou...

在Rails站点中更新Jcrop映像(Update Jcrop image in a Rails site)

问题解决了...... 这个问题起源于coffeescript。 我没有得到Jcrop插件的适当句柄。 两个问题,基本上。 获取Jcrop句柄的正确coffeescript语法: class ProfilePicCropper constructor: -> $('#cropbox').Jcrop aspectRatio: 1 setSelect: [0, 0, 600, 600] onSelect: @update onChange: ...

在ajax上载中实现JCrop(Implementing JCrop in ajax upload)

它不起作用,因为你通过ajax调用来获取图像。 当您在document.ready上调用jcrop函数时,图像不存在。 在DOM中添加图像后,您需要将jcrop代码放入ajax调用的成功函数中。 应该是这样的(未测试): $.ajaxFileUpload({ url: '<?php echo site_url()?>/upload/do_upload', secureuri: false, fileElementId:...

弄乱了Jcrop的大小(Messing up Jcrop size)

好的,我现在整理好了..现在我只是检查Jcrop发送的高度和宽度是否符合我想要的宽高比! 万一其他人需要这个: function GCD($a, $b) { while ($b != 0) { $remainder = $a % $b; $a = $b; $b = $remainder; } $a = abs($a); return $a; } $a = $_POST['w']; // width $b = $_PO...

使用Jcrop裁剪上传的图像(Cropping Uploaded Image using Jcrop)

图像显示为黑色的问题正在发生,因为您在实际加载之前在图像上调用jCrop。 您可以在reader.onload调用之后将调用放入jCrop,以便在图像加载后运行。 看到这个: reader.onload = function (e) { $('#blah').attr('src', e.target.result); $('.crop').Jcrop({ onSelect: updateCoords, bgOpacity: ...

JCrop和PHP GD返回带有黑条的图像(JCrop and PHP GD return an image with a black bar)

你可能想看看imagecopyresampled http://php.net/manual/en/function.imagecopyresampled.php 如果你是用gif和png创建的,你可能需要额外的选项,比如colorallocate 这个想法是你调整图像大小并用正确的像素填充这个图像,所以gd不需要用黑色像素(黑色条)完成图像。 希望这可以帮助。 For what it's worth, I managed to solve my own problem. The issue wa...

角度文件上载,jCrop和旋转(Angular File Upload, jCrop, and Rotate)

我的同事解决了我的问题,我希望这会有助于其他人! https://github.com/LukeMason/angular-img-editor My colleague solved my problem and I hope this will help others! https://github.com/LukeMason/angular-img-editor

modalpopupextender中Jcrop(图像).setOptions的jquery委托事件(jquery delegate event for Jcrop(image).setOptions in a modalpopupextender)

对于未来的访问者,我能够通过在window.focus中使用setOptions事件而不是window.load来使其工作。 jQuery(window).focus(function () { $.Jcrop(image).setOptions({ ..... }); }); For future visitors, I was able to make it work by having the setOptions event inside the window.focus ins...

相关文章

更多

《编程之道 Java》(Program JAVA)[ISO]

本教材的第1章到第7章讲述了怎样学习Java和Java的基础知识,以及面向对象的编程思想;第8章到第1 ...

I18N 国际化 简介

软件的国际化: 软件开发时,要使它能同时应对世界不同地区和国家的访问,并针对不同地区和国家的访问,提 ...

Hadoop的I/O

1. 数据完整性:任何语言对IO的操作都要保持其数据的完整性。Hadoop当然希望数据在存储和处理中不 ...

Hadoop I/O系统介绍

看过很多Hadoop介绍或者是学习的帖子和文章,发现介绍Hadoop I/O系统的很少。很多文章都会介 ...

[转]Top 20 Programming Lessons I've Learned in 20 Years

This post could be viewed as hard lessons learned f ...

Tomcat源码里,return (factory)有特殊作用么

/** * Return the SAXParserFactory we will use, ...

Bentley.STAAD.RCDC.V8i.04.01.01.03 1CD

1、Bentley Multiframe Advanced V8i SS3 17.00.02.10 W ...

《Java 2 图形设计卷I:AWT》(Graphic Java 1.2 Mastering the JFC Volume I:AWT )扫描版[PDF]

中文名: Java 2 图形设计卷I:AWT 原名: Graphic Java 1.2 Mast ...

I18n的一个问题

升级了,2.2.2, 用了I18n. 问题来了。 以前model validation 出错的默认消 ...

最新问答

更多

您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)

将diff文件复制到存储库的根目录,然后执行以下操作: git apply yourcoworkers.diff 有关apply命令的更多信息, apply 见其手册页 。 顺便说一下:一个更好的方法是通过文件交换整个提交文件是发送者上的命令git format-patch ,然后在接收器上加上git am ,因为它也传送作者信息和提交信息。 如果修补程序应用程序失败,并且生成diff的提交实际上在您的备份中,则可以使用尝试在更改中合并的apply程序的-3选项。 它还适用于Unix管道,如下

将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)

尝试将第二行更改为snprintf(buf1, sizeof buf1, "%.2f", balance1); 。 另外,为什么要声明用该特定表达式分配缓冲区的存储量? EDIT @LưuVĩnhPhúc在下面的评论中提到我的原始答案中的格式说明符将舍入而不是截断,因此根据如何在不使用C舍入的情况下截断小数,您可以执行以下操作: float balance = 200.56866; int tmp = balance1 * 100; float balance1 = tmp / 100.0; c

OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)

这是简单的解决方案 在你需要写的控制器中 BackendMenu::setContext('Archetypics.Team', 'website', 'team'); 请参阅https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code'); 你需要在r

页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)

每当发出请求时ASP都会创建一个新的Page对象,并且一旦它将响应发送回用户就不会保留对该Page对象的引用,因此只要你找不到某种方法来保持生命自己引用该Page对象后,一旦发送响应, Page和只能通过该页面访问的所有对象才有资格进行垃圾回收。 ASP creates a new Page object whenever a request is made, and it does not hold onto the reference to that Page object once it

codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)

要在生产服务器中调试这个,你可以临时放 error_reporting(E_ALL); 并查看有哪些其他错误阻止正确的重定向。 您还应该检查生产服务器发送的响应标头。 它是否具有“缓存”,是否需要重新验证标头等 to debug this in production server, you can temporary put error_reporting(E_ALL); and see what other errors are there that prevents the proper

在计算机拍照在哪里进入

打开娥的电脑.在下面找到视频设备点击进去就可以了...

使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)

你是对的。 第一次输入后,换行符将保留在输入缓冲区中。 第一次读取后尝试插入: cin.ignore(); // to ignore the newline character 或者更好的是: //discards all input in the standard input stream up to and including the first newline. cin.ignore(numeric_limits::max(), '\n'); 您必须为#inc

No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)

for (int k = 0; k > 10; k++) { System.out.println(k); } k不大于10,所以循环将永远不会执行。 我想要什么是k<10 ,不是吗? for (int k = 0; k < 10; k++) { System.out.println(k); } for (int k = 0; k > 10; k++) { System.out.println(k); } k is not greater than 10, so loop

单页应用程序:页面重新加载(Single Page Application: page reload)

优点是不注销会避免惹恼用户,以至于他们会想要杀死你:-)。 说真的,如果每次刷新页面时应用程序都会将我注销(或者在新选项卡中打开一个链接),我再也不会使用该应用程序了。 好吧,不要这样做。 确保身份验证令牌存储在刷新后的某个位置,即不在某些JS变量中,而是存储在cookie或本地存储中。 The advantage is that not logging off will avoid pissing off your users so much that they'll want to kill

在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)

EXECUTE IMMEDIATE 'SELECT '||field_val_temp ||' FROM tableb WHERE function_id = :func_val AND rec_key = :rec_key' INTO field_val USING 'STDCUSAC' , yu.rec_key; 和, EXECUTE IMMEDIATE 'UPDATE tablec SET field_val_'||i||' = :field_val' USI