Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
format all
Browse files Browse the repository at this point in the history
  • Loading branch information
Singularity0909 committed Feb 4, 2021
1 parent af44f8d commit 2eec1e9
Show file tree
Hide file tree
Showing 12 changed files with 736 additions and 1,603 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
"contributions": [
"code"
]
},
{
"login": "superzhaoyang",
"name": "superzhaoyang",
"avatar_url": "https://avatars.githubusercontent.com/u/49988452?v=4",
"profile": "http://www.superzhaoyang.top",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 0 additions & 3 deletions ClickToRun.cmd

This file was deleted.

41 changes: 0 additions & 41 deletions ConfigureOnce.ps1

This file was deleted.

80 changes: 2 additions & 78 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SDUHealth
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

山东大学学生每日健康状况填报自动打卡。
Expand All @@ -13,83 +13,6 @@

**[Python3](https://www.python.org)**

推荐使用 GitHub Actions 的运行方式,可以方便的实现每日自动打卡。

注意需要你使用本程序打卡前一天手动打过卡,且当天没有打过卡,之后每天就可以都只使用自动打卡了。

### Github Actions 运行

首先复制 configexample.yml 文件里面的所有内容,然后在本地进行编辑,根据文件的指示填入账号和密码,之后可以去 [yaml检测](https://www.bejson.com/validators/yaml_editor/) 检测一下文件的正确性,支持多账户,当然前提是你知道别人的密码。

之后 fork 本仓库到自己的 GitHub 账号,之后打开仓库的 Settings,在仓库设置界面在打开 Secrets 选项:

![Github Repo Secrets Settings](https://cdn.jsdelivr.net/gh/viewv/Pico@master/uPic/Screen%20Shot%202021-01-19%20at%2019.06.10.png)

之后新建一个 secret,Name 为 CONFIG,Value 就是你编辑的包含你的学号密码的 yaml 文件内容全部复制进去即可:

![New Github Repo Secret](https://cdn.jsdelivr.net/gh/viewv/Pico@master/uPic/Screen%20Shot%202021-01-19%20at%2019.08.02.png)

保存即可,之后转到仓库的 Actions 选项卡:

![Enable Github Actions workflow](https://cdn.jsdelivr.net/gh/viewv/Pico@master/uPic/Screen%20Shot%202021-01-19%20at%2019.09.06.png)

Enable 本仓库已经配置好的 GitHub Actions workflow,之后点击 checkin 打开配置选项:

![Enable checkin workflow](https://cdn.jsdelivr.net/gh/viewv/Pico@master/uPic/Screen%20Shot%202021-01-21%20at%2015.11.44.png)

Enable workflow,之后得到下面的界面:

![Checkin workflow page](https://cdn.jsdelivr.net/gh/viewv/Pico@master/uPic/Screen%20Shot%202021-01-21%20at%2015.12.33.png)

你现在可以选择 Run workflow 手动触发运行,本仓库也配置了每天的自动运行,你可以打开 GitHub Actions 的运行结果提示,这样就可以简单的实现每天的打卡任务。

> ⚠️ 注意
>
> 最近我们发现 GitHub Actions workflow 有延时问题, 有可能您的实际运行时间与设置的不同。
>
> 又由于 GitHub 可能的设计问题,您有可能需要先手动运行一次打卡 workflow 才可以激活定时运行。
<details>
<summary>关于 repo_sync.yml 的使用说明</summary>

这个文件创建了一个定时自动同步源仓库内所有代码的 Github Actions workflow。

> ⚠️ 注意
>
> 该 workflow 执行后会自动覆盖原仓库内的所有代码,并更新为源仓库的代码,所有自定义的修改将不会得到保留(一般来说,也没什么需要自定义的,实在是需要自定义,可以手动执行该 workflow 之后,将其设置为 disable )。
在 fork 了代码之后,首先需要去申请一个 GitHub Personal Access Token,该 Token 让此 workflow 拥有了更改指定仓库代码的权限。具体操作如下:

先选择账户 Settings

![Github account Settings](https://cdn.jsdelivr.net/gh/nekomiao123/pic/img/image-20210121121329851.png)

然后选择 Developer Settings

![Github Developer Settings](https://cdn.jsdelivr.net/gh/nekomiao123/pic/img/image-20210121121525838.png)

之后再选择 Personal access tokens 点击里面的 Generate new token

![Generate new token](https://cdn.jsdelivr.net/gh/nekomiao123/pic/img/image-20210121121640260.png)

之后先随便取个好记的名字,然后勾选前两项

![New personal access token](https://cdn.jsdelivr.net/gh/nekomiao123/pic/img/image-20210121121747207.png)

最后点击下面的 Generate token 即可,这样就能获得一串类似这样的字符,赶紧复制下来,它只会显示这一次

![Personal token info](https://cdn.jsdelivr.net/gh/nekomiao123/pic/img/image-20210121121953685.png)

然后去新建一个 secret(跟上面建立 secret 的流程一样)

Name 是 PAT

Value 是刚才你复制的这一串字符

</details>

到这里,该 Github Actions workflow 就可以使用了,可以实现每日自动打卡,如果你也开启了 repo_sync workflow 那么也将定时自动同步本仓库以保持代码更新。

### 本地运行

在本地安装好环境后,下载或者 clone 本仓库后,到项目文件夹下运行如下命令安装 Python 所需依赖:
Expand Down Expand Up @@ -130,6 +53,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://nekokiku.cn/"><img src="https://avatars3.githubusercontent.com/u/34064940?v=4?s=100" width="100px;" alt=""/><br /><sub><b>menma</b></sub></a><br /><a href="https://github.com/viewv/sduhealth/commits?author=nekomiao123" title="Code">💻</a></td>
<td align="center"><a href="https://www.macrohard.cn"><img src="https://avatars.githubusercontent.com/u/44798266?v=4?s=100" width="100px;" alt=""/><br /><sub><b>2U</b></sub></a><br /><a href="https://github.com/viewv/sduhealth/commits?author=Singularity0909" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ryuujo1573"><img src="https://avatars.githubusercontent.com/u/16525512?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryuujo Zhang</b></sub></a><br /><a href="https://github.com/viewv/sduhealth/commits?author=ryuujo1573" title="Code">💻</a></td>
<td align="center"><a href="http://www.superzhaoyang.top"><img src="https://avatars.githubusercontent.com/u/49988452?v=4?s=100" width="100px;" alt=""/><br /><sub><b>superzhaoyang</b></sub></a><br /><a href="https://github.com/viewv/sduhealth/commits?author=superzhaoyang" title="Code">💻</a></td>
</tr>
</table>

Expand Down
68 changes: 35 additions & 33 deletions des.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
PAD_NORMAL = 1
PAD_PKCS5 = 2


# PAD_PKCS5: is a method that will unambiguously remove all padding
# characters after decryption, when originally encrypted with
# this padding mode.
Expand Down Expand Up @@ -219,7 +220,7 @@ def _unpadData(self, data, pad, padmode):
pad = self.getPadding()
if pad:
data = data[:-self.block_size] + \
data[-self.block_size:].rstrip(pad)
data[-self.block_size:].rstrip(pad)

elif padmode == PAD_PKCS5:
if _pythonMajorVersion < 3:
Expand Down Expand Up @@ -248,6 +249,7 @@ def _guardAgainstUnicode(self, data):
"pyDes can only work with encoded strings, not Unicode.")
return data


#############################################################################
# DES #
#############################################################################
Expand Down Expand Up @@ -299,37 +301,37 @@ class des(_baseDes):

# permuted choice key (table 2)
__pc2 = [
13, 16, 10, 23, 0, 4,
2, 27, 14, 5, 20, 9,
22, 18, 11, 3, 25, 7,
15, 6, 26, 19, 12, 1,
13, 16, 10, 23, 0, 4,
2, 27, 14, 5, 20, 9,
22, 18, 11, 3, 25, 7,
15, 6, 26, 19, 12, 1,
40, 51, 30, 36, 46, 54,
29, 39, 50, 44, 32, 47,
43, 48, 38, 55, 33, 52,
45, 41, 49, 35, 28, 31
]

# initial permutation IP
__ip = [57, 49, 41, 33, 25, 17, 9, 1,
__ip = [57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 45, 37, 29, 21, 13, 5,
63, 55, 47, 39, 31, 23, 15, 7,
56, 48, 40, 32, 24, 16, 8, 0,
56, 48, 40, 32, 24, 16, 8, 0,
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6
]

# Expansion table for turning 32 bit blocks into 48 bits
__expansion_table = [
31, 0, 1, 2, 3, 4,
3, 4, 5, 6, 7, 8,
7, 8, 9, 10, 11, 12,
31, 0, 1, 2, 3, 4,
3, 4, 5, 6, 7, 8,
7, 8, 9, 10, 11, 12,
11, 12, 13, 14, 15, 16,
15, 16, 17, 18, 19, 20,
19, 20, 21, 22, 23, 24,
23, 24, 25, 26, 27, 28,
27, 28, 29, 30, 31, 0
27, 28, 29, 30, 31, 0
]

# The (in)famous S-boxes
Expand Down Expand Up @@ -395,14 +397,14 @@ class des(_baseDes):

# final permutation IP^-1
__fp = [
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25,
32, 0, 40, 8, 48, 16, 56, 24
39, 7, 47, 15, 55, 23, 63, 31,
38, 6, 46, 14, 54, 22, 62, 30,
37, 5, 45, 13, 53, 21, 61, 29,
36, 4, 44, 12, 52, 20, 60, 28,
35, 3, 43, 11, 51, 19, 59, 27,
34, 2, 42, 10, 50, 18, 58, 26,
33, 1, 41, 9, 49, 17, 57, 25,
32, 0, 40, 8, 48, 16, 56, 24
]

# Type of crypting being done
Expand Down Expand Up @@ -528,8 +530,8 @@ def __des_crypt(self, block, crypt_type):
B = [self.R[:6], self.R[6:12], self.R[12:18], self.R[18:24],
self.R[24:30], self.R[30:36], self.R[36:42], self.R[42:]]
# Optimization: Replaced below commented code with above
#j = 0
#B = []
# j = 0
# B = []
# while j < len(self.R):
# self.R[j] = self.R[j] ^ self.Kn[iteration][j]
# j += 1
Expand Down Expand Up @@ -563,7 +565,7 @@ def __des_crypt(self, block, crypt_type):
# Xor with L[i - 1]
self.R = list(map(lambda x, y: x ^ y, self.R, self.L))
# Optimization: This now replaces the below commented code
#j = 0
# j = 0
# while j < len(self.R):
# self.R[j] = self.R[j] ^ self.L[j]
# j += 1
Expand Down Expand Up @@ -609,25 +611,25 @@ def crypt(self, data, crypt_type):
i = 0
dict = {}
result = []
#cached = 0
#lines = 0
# cached = 0
# lines = 0
while i < len(data):
# Test code for caching encryption results
#lines += 1
# lines += 1
# if dict.has_key(data[i:i+8]):
# print "Cached result for: %s" % data[i:i+8]
# cached += 1
# result.append(dict[data[i:i+8]])
# i += 8
# continue

block = self.__String_to_BitList(data[i:i+8])
block = self.__String_to_BitList(data[i:i + 8])

# Xor with IV if using CBC mode
if self.getMode() == CBC:
if crypt_type == des.ENCRYPT:
block = list(map(lambda x, y: x ^ y, block, iv))
#j = 0
# j = 0
# while j < len(block):
# block[j] = block[j] ^ iv[j]
# j += 1
Expand All @@ -637,7 +639,7 @@ def crypt(self, data, crypt_type):
if crypt_type == des.DECRYPT:
processed_block = list(
map(lambda x, y: x ^ y, processed_block, iv))
#j = 0
# j = 0
# while j < len(processed_block):
# processed_block[j] = processed_block[j] ^ iv[j]
# j += 1
Expand All @@ -648,10 +650,10 @@ def crypt(self, data, crypt_type):
processed_block = self.__des_crypt(block, crypt_type)

# Add the resulting crypted block to our list
#d = self.__BitList_to_String(processed_block)
# d = self.__BitList_to_String(processed_block)
# result.append(d)
result.append(self.__BitList_to_String(processed_block))
#dict[data[i:i+8]] = d
# dict[data[i:i+8]] = d
i += 8

# print "Lines: %d, cached: %d" % (lines, cached)
Expand Down Expand Up @@ -811,7 +813,7 @@ def encrypt(self, data, pad=None, padmode=None):
i = 0
result = []
while i < len(data):
block = self.__key1.crypt(data[i:i+8], ENCRYPT)
block = self.__key1.crypt(data[i:i + 8], ENCRYPT)
block = self.__key2.crypt(block, DECRYPT)
block = self.__key3.crypt(block, ENCRYPT)
self.__key1.setIV(block)
Expand Down Expand Up @@ -856,8 +858,8 @@ def decrypt(self, data, pad=None, padmode=None):
i = 0
result = []
while i < len(data):
iv = data[i:i+8]
block = self.__key3.crypt(iv, DECRYPT)
iv = data[i:i + 8]
block = self.__key3.crypt(iv, DECRYPT)
block = self.__key2.crypt(block, ENCRYPT)
block = self.__key1.crypt(block, DECRYPT)
self.__key1.setIV(iv)
Expand Down
Loading

0 comments on commit 2eec1e9

Please sign in to comment.