Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pass="rynrtyncg";
- var passComplexityRank=
- {
- DoesNotMeetComplexityDefinition: 0,
- VeryWeak: 1,
- Weak: 2,
- Fair: 3,
- Medium: 4,
- Strong: 5,
- VeryStrong: 6,
- Simple: 7,
- };
- function ValidatePassword(pass) {//Vraca result broj
- var score = 1;
- var lowerCase = 0;
- var upperCase = 0;
- var digits = 0;
- if ((pass.length | 0) > 5) {
- if (System.Linq.Enumerable.from(System.String.toCharArray(pass, 0, pass.length)).distinct().count() === 1 || System.String.contains(("012345678909876543210"),pass)) {
- var result = passComplexityRank.Simple;
- return result;
- }
- }
- if ((password.length | 0) < 6) {
- result = passComplexityRank.DoesNotMeetComplexityDefinition;
- }
- else if ((password.length | 0) < 8) {
- result = passComplexityRank.VeryWeak;
- }
- else {
- for (var i = 0; i < (password.length | 0) ; i = ((i + 1) | 0)) {
- var c = (password[i]);
- if (c.IsLower(c)) {
- lowerCase = ((lowerCase + 1) | 0);
- }
- if (c.IsUpper(c)) {
- upperCase = ((upperCase + 1) | 0);
- }
- if (c.IsDigit(c)) {
- digits = ((digits + 1) | 0);
- }
- }
- if ((password.length | 0) >= 8) {
- score = ((score + 1) | 0);
- }
- if ((password.length | 0) >= 12) {
- score = ((score + 1) | 0);
- }
- if (lowerCase > 0) {
- score = ((score + 1) | 0);
- }
- if (upperCase > 0) {
- score = ((score + 1) | 0);
- }
- if (digits > 0) {
- score = ((score + 1) | 0);
- }
- result = score;
- }
- return result;
- };
- function Program_scoreMessage(score) {//Vraca poruku u zavisnosti od scora
- switch (score) {
- case 0:
- var result = "Lozinka ne ispunjava zahtevanu slo\u0415\u0455enost.";
- break;
- case 1:
- result = "Slo\u0415\u0455enost lozinke : jako slaba";
- break;
- case 2:
- result = "Slo\u0415\u0455enost lozinke : slaba";
- break;
- case 3:
- result = "Slo\u0415\u0455enost lozinke : umerena";
- break;
- case 4:
- result = "Slo\u0415\u0455enost lozinke : srednja";
- break;
- case 5:
- result = "Slo\u0415\u0455enost lozinke : jaka";
- break;
- case 6:
- result = "Slo\u0415\u0455enost lozinke : veoma jaka";
- break;
- case 7:
- result = "Lozinka je suvi\u0415\u040ee jednostavna.";
- break;
- default:
- result = "";
- break;
- }
- return result;
- };
- console.log("aaaaaa");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement