Skip to content

Commit

Permalink
encrypt name
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Apr 17, 2020
1 parent 6735b9b commit 974fec0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [课件网盘地址我懒得记--url_jump](./url_jump)
- [其他](./other)
- [16进制转2进制——计算误码率](./other/hex2bin.py)
- [姓名按拼音加密](./other/encrypt_name.py)
- [爬虫](./spider)
- [考满分万能句型练习数据爬取](./spider/KMF_write_sentence.ipynb)
- [慕课课件下载](./spider/慕课课件下载.ipynb)
17 changes: 17 additions & 0 deletions other/encrypt_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pandas as pd
from pypinyin import lazy_pinyin as lpy

abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

data = pd.read_csv("xxx.csv")
names = list(set(data["name"]))

name_abbrs, name_encry = [], []
for name in names:
abbr, encry = "", ""
for py in lpy(name):
letter = py[0].title()
abbr += letter
encry += abc[(abc.index(letter) + len(name)) % len(abc)]
name_abbrs.append(abbr)
name_encry.append(encry)

0 comments on commit 974fec0

Please sign in to comment.