mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-18 17:10:04 +00:00
fix the maximum generate password
This commit is contained in:
parent
c590c672a1
commit
929a645071
3 changed files with 12 additions and 3 deletions
|
@ -35,7 +35,7 @@ en:
|
||||||
import: "Import item since a CSV file"
|
import: "Import item since a CSV file"
|
||||||
force: "Force an action"
|
force: "Force an action"
|
||||||
format: "Change the display items format by an alternative format"
|
format: "Change the display items format by an alternative format"
|
||||||
generate_password: "Generate a random password (default 8 characters, max 63 characters)"
|
generate_password: "Generate a random password (default 8 characters)"
|
||||||
help: "Show this help message"
|
help: "Show this help message"
|
||||||
form:
|
form:
|
||||||
add:
|
add:
|
||||||
|
|
|
@ -35,7 +35,7 @@ fr:
|
||||||
import: "Importe des éléments depuis un fichier au format CSV"
|
import: "Importe des éléments depuis un fichier au format CSV"
|
||||||
force: "Force une action, l'action ne demandera pas de confirmation"
|
force: "Force une action, l'action ne demandera pas de confirmation"
|
||||||
format: "Change le format d'affichage des éléments par un alternatif"
|
format: "Change le format d'affichage des éléments par un alternatif"
|
||||||
generate_password: "Génére un mot de passe aléatoire (défaut 8 caractères, max 63 caractères)"
|
generate_password: "Génére un mot de passe aléatoire (défaut 8 caractères)"
|
||||||
help: "Affiche ce message d'aide"
|
help: "Affiche ce message d'aide"
|
||||||
form:
|
form:
|
||||||
add:
|
add:
|
||||||
|
|
11
lib/MPW.rb
11
lib/MPW.rb
|
@ -360,9 +360,18 @@ class MPW
|
||||||
def self.generatePassword(length=8)
|
def self.generatePassword(length=8)
|
||||||
if length.to_i <= 0
|
if length.to_i <= 0
|
||||||
length = 8
|
length = 8
|
||||||
|
else
|
||||||
|
length = length.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
return ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(length.to_i).join
|
result = ''
|
||||||
|
while length > 62 do
|
||||||
|
result << ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(62).join
|
||||||
|
length -= 62
|
||||||
|
end
|
||||||
|
result << ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(length).join
|
||||||
|
|
||||||
|
return result
|
||||||
#return ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]-%w(0 1 I O l i o)).sample(length).join
|
#return ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]-%w(0 1 I O l i o)).sample(length).join
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue