-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ll104567/master
I do some fix
- Loading branch information
Showing
22 changed files
with
306 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,30 @@ | ||
# profake | ||
python生成随机字符、中英文用户名、手机号、身份证等 | ||
|
||
-------- | ||
|
||
### 自测试结果: | ||
|
||
``` | ||
==========1.身份证号========== | ||
607036710724717 | ||
992882199403012402 | ||
261449199110098011 | ||
38904119840102030X | ||
YES,15位身份证号正确! | ||
YES,18位身份证号正确! | ||
YES,18位身份证号正确! | ||
==========2.手机号========== | ||
13944898670 | ||
13479416245 | ||
13523563365 | ||
==========3.随机数========== | ||
82 | ||
69437243589733545059 | ||
8340710961 | ||
==========4.用户名========== | ||
于眉 | ||
葛雁梁朗 | ||
施中韵 | ||
潘馥 | ||
Fquplm | ||
Aaythunppybhhzbhiwff | ||
==========5.邮箱========== | ||
ab@J.J | ||
Iqi@S.S | ||
0@qq.com | ||
DS@qq.com | ||
m@sina.com | ||
zbFDQqBr@f.f | ||
W@B.B | ||
参数过小,无法生成! | ||
EKMdPQUgs@s.s | ||
zOTdCYg@qq.com | ||
==========5.IP地址========== | ||
24.201.108.4 | ||
192.30.25.44 | ||
192.168.74.78 | ||
192.168.136.97 | ||
``` | ||
#profake<br> | ||
python生成随机字符、中英文用户名、手机号、身份证等<br> | ||
|
||
test ok : python 3.7 | ||
Usage:<br> | ||
|
||
from fake_modules.utils.tools import * <br> | ||
from fake_modules.fake_email import email<br> | ||
from fake_modules.fake_id import make_id,check_id<br> | ||
from fake_modules.fake_ip import ip<br> | ||
from fake_modules.fake_name import name<br> | ||
from fake_modules.fake_number import number<br> | ||
from fake_modules.fake_phone import phone<br> | ||
|
||
├── fake_modules<br> | ||
│ ├── fake_email.py<br> | ||
│ ├── fake_id.py<br> | ||
│ ├── fake_ip.py<br> | ||
│ ├── fake_name.py<br> | ||
│ ├── fake_number.py<br> | ||
│ ├── fake_phone.py<br> | ||
│ ├── __init__.py<br> | ||
│ └── utils<br> | ||
│ ├── __init__.py<br> | ||
│ └── tools.py<br> | ||
├── __init__.py<br> | ||
└── README.md<br> | ||
|
||
2 directories, 11 files<br> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/python3 | ||
|
||
from fake_modules.utils.tools import * | ||
from fake_modules.fake_email import email | ||
from fake_modules.fake_id import make_id,check_id | ||
from fake_modules.fake_ip import ip | ||
from fake_modules.fake_name import name | ||
from fake_modules.fake_number import number | ||
from fake_modules.fake_phone import phone |
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import random | ||
import string | ||
from fake_modules.utils.tools import get_number,get_lowercase,get_letter,get_mix | ||
|
||
def _email(): | ||
"""生成邮箱地址""" | ||
array1 = ['126.com', '163.com', 'sina.com', 'sohu.com', 'yahoo.com.cn', 'gmail.com','yahoo.com'] | ||
array2 = ['qq.com'] | ||
|
||
array = random.choice([array1,array2]) | ||
address = random.choice(array) | ||
if array == array2: | ||
salt = get_number(9) | ||
if salt.startswith('0'): | ||
user = '1' + salt | ||
else: | ||
user = salt | ||
else: | ||
user = get_lowercase(random.randint(6,10)) | ||
|
||
fake_email = user + '@' + address | ||
return fake_email | ||
|
||
def email(n=1): | ||
''' | ||
生成随机邮箱 | ||
n = 1 return str | ||
n > 1 return list for str | ||
''' | ||
s = [] | ||
for i in range(n): | ||
s.append(_email()) | ||
if len(s) == 1: | ||
return s[0] | ||
else: | ||
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import random | ||
import string | ||
import time | ||
|
||
def make_id(): | ||
"""随机生成18为身份证""" | ||
ARR = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2) | ||
LAST = ('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2') | ||
t = time.localtime()[0] # 年份 | ||
k = '{:0>2}{:0>2}{:0>2}{:0>4}{:0>2}{:0>2}{:0>3}'.format(random.randint(10, 99), | ||
random.randint(1, 99), | ||
random.randint(1, 99), | ||
random.randint(t - 80, t - 18), | ||
random.randint(1, 12), | ||
random.randint(1, 28), | ||
random.randint(1, 999)) | ||
y = 0 | ||
for i in range(17): | ||
y += int(k[i]) * ARR[i] | ||
return '%s%s' % (k, LAST[y % 11]) | ||
|
||
def check_id(ID): | ||
''' | ||
检查身份证是不是符合要求 ARP为每个数字的权重 | ||
''' | ||
ARR = (7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2) | ||
LAST = ('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2') | ||
xlen = len(str(ID)) | ||
if xlen != 18: | ||
return False | ||
try: | ||
if xlen == 18: | ||
x2 = ID[6:14] | ||
x3 = time.strptime(x2, '%Y%m%d') | ||
if x2 < '19000101' or x3 > time.localtime(): | ||
return False | ||
else: | ||
x2 = time.strptime(ID[6:12], '%y%m%d') | ||
except: | ||
return False | ||
if xlen == 18: | ||
y = 0 | ||
for i in range(17): | ||
y += int(ID[i]) * ARR[i] | ||
|
||
if LAST[y % 11] != ID[-1].upper(): | ||
return False | ||
return True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import random | ||
import string | ||
|
||
|
||
def _ip(): | ||
|
||
return '{}.{}.{}.{}'.format(random.randint(0,255),random.randint(0,255),random.randint(0,255),random.randint(0,255)) | ||
|
||
def ip(n=1): | ||
|
||
s = [] | ||
for i in range(n): | ||
s.append(_ip()) | ||
|
||
if n == 1: | ||
return s[0] | ||
else: | ||
return s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import random | ||
|
||
def name(Language='cn', count=2): | ||
"""生成随机用户名,参数Language为中文用户或英文用户,参数count为用户名位数""" | ||
if Language.lower() == 'cn': | ||
array1 = ['赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '褚', '卫', '蒋', '沈', '韩', '杨', '朱', | ||
'秦', '尤', '许', '何', '吕', '施', '张', '孔', '曹', '严', '华', '金', '魏', '陶', '姜', '戚', '谢', | ||
'邹', '喻', '柏', '水', '窦', '章', '云', '苏', '潘', '葛', '奚', '范', '彭', '郎', '鲁', '韦', '昌', | ||
'马', '苗', '凤', '花', '方', '俞', '任', '袁', '柳', '酆', '鲍', '史', '唐', '费', '廉', '岑', '薛', | ||
'雷', '贺', '倪', '汤', '滕', '殷', '罗', '毕', '郝', '邬', '安', '常', '乐', '于', '时', '傅', '皮', | ||
'卞', '齐', '康', '伍', '余', '元', '卜', '顾', '孟', '平', '黄', '和', '穆', '萧', '尹', '姚', '邵', | ||
'堪', '汪', '祁', '毛', '禹', '狄', '米', '贝', '明', '臧', '计', '伏', '成', '戴', '谈', '宋', '茅', | ||
'庞', '熊', '纪', '舒', '屈', '项', '祝', '董', '梁'] | ||
array2 = ['秀', '娟', '英', '华', '慧', '巧', '美', '娜', '静', '淑', '惠', '珠', '翠', '雅', '玉', '萍', '红', | ||
'娥', '玲', '芬', '芳', '燕', '彩', '春', '菊', '兰', '凤', '梅', '琳', '素', '云', '莲', '真', '环', | ||
'雪', '荣', '爱', '妹', '霞', '香', '莺', '媛', '艳', '瑞', '凡', '佳', '嘉', '琼', '勤', '珍', '贞', | ||
'莉', '桂', '叶', '璧', '璐', '娅', '琦', '晶', '妍', '茜', '秋', '珊', '莎', '锦', '黛', '倩', '婷', | ||
'姣', '婉', '娴', '瑾', '颖', '露', '瑶', '怡', '婵', '雁', '蓓', '仪', '荷', '丹', '蓉', '眉', '君', | ||
'琴', '蕊', '薇', '菁', '梦', '岚', '苑', '柔', '竹', '霭', '凝', '晓', '欢', '霄', '枫', '芸', '菲', | ||
'寒', '欣', '滢', '伊', '亚', '宜', '可', '姬', '舒', '影', '荔', '枝', '思', '丽', '秀', '飘', '育', | ||
'馥', '琦', '晶', '妍', '茜', '秋', '珊', '莎', '锦', '黛', '青', '倩', '婷', '宁', '蓓', '纨', '苑', | ||
'婕', '馨', '瑗', '琰', '韵', '融', '园', '艺', '咏', '卿', '聪', '澜', '纯', '毓', '悦', '昭', '冰', | ||
'爽', '琬', '茗', '羽', '希', '伟', '刚', '勇', '毅', '俊', '峰', '强', '军', '平', '保', '东', '文', | ||
'辉', '明', '永', '健', '世', '广', '志', '义', '兴', '良', '海', '山', '仁', '波', '贵', '福', '生', | ||
'龙', '元', '全', '国', '胜', '学', '祥', '才', '发', '武', '新', '清', '飞', '彬', '富', '顺', '信', | ||
'子', '杰', '涛', '昌', '成', '康', '星', '天', '达', '安', '岩', '中', '茂', '进', '林', '有', '坚', | ||
'和', '彪', '诚', '先', '敬', '震', '振', '壮', '会', '思', '群', '豪', '心', '邦', '承', '乐', '功', | ||
'松', '善', '厚', '庆', '磊', '民', '友', '裕', '河', '哲', '江', '超', '亮', '政', '谦', '亨', '奇', | ||
'固', '之', '轮', '翰', '朗', '伯', '宏', '言', '鸣', '朋', '斌', '梁', '栋', '维', '启', '克', '伦', | ||
'翔', '旭', '鹏', '泽', '辰', '士', '以', '建', '家', '致', '树', '炎', '德', '行', '时', '泰', '盛'] | ||
front = array1[random.randint(0, len(array1) - 1)] | ||
last = '' | ||
for i in range(count - 1): | ||
last = last + array2[random.randint(0, len(array2) - 1)] | ||
return '{}{}'.format(front,last) | ||
elif Language.lower() == 'en': | ||
array3 = ['z', 'y', 'x', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', | ||
'g', 'f', 'e', 'd', 'c', 'b', 'a'] | ||
enName = '' | ||
for i in range(count): | ||
enName = enName + array3[random.randint(0, len(array3) - 1)] | ||
return enName.capitalize() | ||
else: | ||
return False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import random | ||
from fake_modules.utils.tools import get_number | ||
|
||
def number(n=10): | ||
return get_number(n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import random | ||
import requests | ||
import socket | ||
import string | ||
import time | ||
|
||
def phone(status=0): | ||
"""生成手机号,参数status为状态,1或其它值代表在线验证后的结果,0表示离线生成的结果""" | ||
while True: | ||
phone = random.choice(['134','135','136','137','138','139','150','151','152','157','158','159','187','188','130','131','132','155','156','185','186','133','153','180','189']) + ''.join(random.choice('0123456789') for i in range(8)) | ||
if status == 0: | ||
return phone | ||
else: | ||
status += 1 | ||
try: | ||
r = requests.get('http://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=' + phone, timeout=2) | ||
obj = eval(r.text.split('=')[1], type('Dummy', (dict,), dict(__getitem__=lambda s, n: n))()) | ||
if obj['telString'] == str(phone): | ||
return phone | ||
except: | ||
if status >= 6: | ||
return phone |
Empty file.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/python | ||
# some functions | ||
import string | ||
import random | ||
|
||
def random_number(): | ||
return random.choice(string.digits) | ||
|
||
def random_lowercase(): | ||
return random.choice(string.ascii_lowercase) | ||
|
||
def random_uppercase(): | ||
return random.choice(string.ascii_uppercase) | ||
|
||
def random_lettercase(): | ||
return random.choice(string.ascii_letters) | ||
|
||
def random_all(): | ||
return random.choice(string.ascii_lowercase+string.digits) | ||
|
||
def get_number(n=10): | ||
s = '' | ||
for i in range(n): | ||
s += random_number() | ||
return s | ||
|
||
def get_lowercase(n=10): | ||
s = '' | ||
for i in range(n): | ||
s += random_lowercase() | ||
return s | ||
|
||
def get_letter(n=10): | ||
s = '' | ||
for i in range(n): | ||
s += random_lettercase() | ||
return s | ||
|
||
def get_mix(n=10): | ||
s = '' | ||
for i in range(n): | ||
s += random_all() | ||
return s | ||
|
Oops, something went wrong.