Skip to content

Commit 723048b

Browse files
author
mohyeah
committed
25/1/30 learning~
1 parent 47b2db7 commit 723048b

1 file changed

Lines changed: 125 additions & 0 deletions

File tree

  • AI Learn/Stage 2 Python Advanced/Chapter 1 Python Advanced Programing
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"id": "initial_id",
6+
"metadata": {
7+
"collapsed": true,
8+
"ExecuteTime": {
9+
"end_time": "2025-01-30T10:48:17.052873Z",
10+
"start_time": "2025-01-30T10:48:17.033286Z"
11+
}
12+
},
13+
"source": "import hashlib",
14+
"outputs": [],
15+
"execution_count": 1
16+
},
17+
{
18+
"metadata": {
19+
"ExecuteTime": {
20+
"end_time": "2025-01-30T10:54:43.013122Z",
21+
"start_time": "2025-01-30T10:54:42.999061Z"
22+
}
23+
},
24+
"cell_type": "code",
25+
"source": [
26+
"# sha256\n",
27+
"sha256_hash = hashlib.new('sha256')\n",
28+
"sha256_hash.update(b'Hello, world!')\n",
29+
"# 输出hex进制哈希值\n",
30+
"print(sha256_hash.hexdigest())"
31+
],
32+
"id": "468bdd8a84880057",
33+
"outputs": [
34+
{
35+
"name": "stdout",
36+
"output_type": "stream",
37+
"text": [
38+
"315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3\n"
39+
]
40+
}
41+
],
42+
"execution_count": 12
43+
},
44+
{
45+
"metadata": {
46+
"ExecuteTime": {
47+
"end_time": "2025-01-30T10:54:45.273817Z",
48+
"start_time": "2025-01-30T10:54:45.262746Z"
49+
}
50+
},
51+
"cell_type": "code",
52+
"source": [
53+
"sha256_hash = hashlib.sha256()\n",
54+
"sha256_hash.update(b'Hello, ')\n",
55+
"sha256_hash.update(b'world!')\n",
56+
"print(sha256_hash.hexdigest())"
57+
],
58+
"id": "389ca86354b4fdc8",
59+
"outputs": [
60+
{
61+
"name": "stdout",
62+
"output_type": "stream",
63+
"text": [
64+
"315f5bdb76d078c43b8ac0064e4a0164612b1fce77c869345bfc94c75894edd3\n"
65+
]
66+
}
67+
],
68+
"execution_count": 13
69+
},
70+
{
71+
"metadata": {
72+
"ExecuteTime": {
73+
"end_time": "2025-01-30T10:55:49.996391Z",
74+
"start_time": "2025-01-30T10:55:49.989616Z"
75+
}
76+
},
77+
"cell_type": "code",
78+
"source": [
79+
"md5_hash = hashlib.md5(b'hello')\n",
80+
"# 输出2进制哈希值\n",
81+
"print(md5_hash.digest())"
82+
],
83+
"id": "c6694a0467df4e13",
84+
"outputs": [
85+
{
86+
"name": "stdout",
87+
"output_type": "stream",
88+
"text": [
89+
"b']A@*\\xbcK*v\\xb9q\\x9d\\x91\\x10\\x17\\xc5\\x92'\n"
90+
]
91+
}
92+
],
93+
"execution_count": 14
94+
},
95+
{
96+
"metadata": {},
97+
"cell_type": "code",
98+
"outputs": [],
99+
"execution_count": null,
100+
"source": "",
101+
"id": "9b9fd24a4155b06a"
102+
}
103+
],
104+
"metadata": {
105+
"kernelspec": {
106+
"display_name": "Python 3",
107+
"language": "python",
108+
"name": "python3"
109+
},
110+
"language_info": {
111+
"codemirror_mode": {
112+
"name": "ipython",
113+
"version": 2
114+
},
115+
"file_extension": ".py",
116+
"mimetype": "text/x-python",
117+
"name": "python",
118+
"nbconvert_exporter": "python",
119+
"pygments_lexer": "ipython2",
120+
"version": "2.7.6"
121+
}
122+
},
123+
"nbformat": 4,
124+
"nbformat_minor": 5
125+
}

0 commit comments

Comments
 (0)