From f48a68ef4a833cca9dbb7b3753c6051c2e9bacb8 Mon Sep 17 00:00:00 2001 From: yjlc-pc Date: Fri, 7 Jun 2024 14:07:43 +0800 Subject: [PATCH] created API "create_password". --- .idea/.gitignore | 3 +++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 7 ++++++ .idea/modules.xml | 8 +++++++ .idea/random-password.iml | 10 ++++++++ .idea/vcs.xml | 6 +++++ README.md | 5 +++- password.py | 23 +++++++++++++++++++ 8 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/random-password.iml create mode 100644 .idea/vcs.xml create mode 100644 password.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1983bd7 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..646ab18 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/random-password.iml b/.idea/random-password.iml new file mode 100644 index 0000000..74d515a --- /dev/null +++ b/.idea/random-password.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 189092e..a4a5d38 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -# random-password \ No newline at end of file +# random-password +This program is not very good.\ +It save use base64.\ +It can only create 2\ 4\ 6\ 8\ 16 byte's password. \ No newline at end of file diff --git a/password.py b/password.py new file mode 100644 index 0000000..75c2a33 --- /dev/null +++ b/password.py @@ -0,0 +1,23 @@ +import random +import base64 +LETTERS = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"] # password's all letter +NUMBERS = [1,2,3,4,5,6,7,8,9] # password's all number +OTHERS = ["`","-","=","[","]",'\\',";","'",".",",","/","~","!","@","#","$","%","^","&","*","(",")","_","+","{","}","|",":","\"","<",">","?"] # password's all fuhao + +def create_password(byte: int): + password = "" + letter_byte = random.randrange(0,byte) + number_byte = random.randrange(0,byte-letter_byte) + other_byte = byte-letter_byte-number_byte + print(letter_byte,number_byte,other_byte) + for _ in range(letter_byte): + password += random.choice(LETTERS) + for _ in range(number_byte): + password += str(random.choice(NUMBERS)) + for _ in range(other_byte): + password += random.choice(OTHERS) + return password + + + +print(create_password(9))