Skip to content

Commit 776aa45

Browse files
committed
Comment decrypt until #95 is available
1 parent 731ea73 commit 776aa45

File tree

1 file changed

+123
-21
lines changed

1 file changed

+123
-21
lines changed

notebooks/encrypt_decrypt.ipynb

Lines changed: 123 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@
44
"metadata": {
55
"colab": {
66
"name": "Encryption examples.ipynb",
7-
"provenance": []
7+
"provenance": [],
8+
"include_colab_link": true
89
},
910
"kernelspec": {
1011
"name": "python3",
1112
"display_name": "Python 3"
12-
},
13-
"accelerator": "GPU"
13+
}
1414
},
1515
"cells": [
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {
19+
"id": "view-in-github",
20+
"colab_type": "text"
21+
},
22+
"source": [
23+
"<a href=\"https://colab.research.google.com/github/pbelevich/csprng/blob/encrypt_decrypt_notebook/notebooks/encrypt_decrypt.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
24+
]
25+
},
1626
{
1727
"cell_type": "markdown",
1828
"metadata": {
@@ -34,15 +44,42 @@
3444
{
3545
"cell_type": "code",
3646
"metadata": {
37-
"id": "jC1O-C25vI0W"
47+
"id": "jC1O-C25vI0W",
48+
"outputId": "beee40f0-7fa8-4354-affd-2fcf18305685",
49+
"colab": {
50+
"base_uri": "https://localhost:8080/"
51+
}
3852
},
3953
"source": [
4054
"# !pip install --pre torchcsprng -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html\n",
4155
"# for CUDA runtime:\n",
4256
"!pip install --pre torchcsprng -f https://download.pytorch.org/whl/nightly/cu101/torch_nightly.html"
4357
],
44-
"execution_count": null,
45-
"outputs": []
58+
"execution_count": 1,
59+
"outputs": [
60+
{
61+
"output_type": "stream",
62+
"text": [
63+
"Looking in links: https://download.pytorch.org/whl/nightly/cu101/torch_nightly.html\n",
64+
"Collecting torchcsprng\n",
65+
"\u001b[?25l Downloading https://download.pytorch.org/whl/nightly/cu101/torchcsprng-0.2.0.dev20201210%2Bcu101-cp36-cp36m-linux_x86_64.whl (4.4MB)\n",
66+
"\u001b[K |████████████████████████████████| 4.4MB 552kB/s \n",
67+
"\u001b[?25hCollecting torch==1.8.0.dev20201210+cu101\n",
68+
"\u001b[?25l Downloading https://download.pytorch.org/whl/nightly/cu101/torch-1.8.0.dev20201210%2Bcu101-cp36-cp36m-linux_x86_64.whl (788.6MB)\n",
69+
"\u001b[K |████████████████████████████████| 788.6MB 25kB/s \n",
70+
"\u001b[?25hRequirement already satisfied: typing-extensions in /usr/local/lib/python3.6/dist-packages (from torch==1.8.0.dev20201210+cu101->torchcsprng) (3.7.4.3)\n",
71+
"Requirement already satisfied: dataclasses; python_version < \"3.7\" in /usr/local/lib/python3.6/dist-packages (from torch==1.8.0.dev20201210+cu101->torchcsprng) (0.8)\n",
72+
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from torch==1.8.0.dev20201210+cu101->torchcsprng) (1.18.5)\n",
73+
"\u001b[31mERROR: torchvision 0.8.1+cu101 has requirement torch==1.7.0, but you'll have torch 1.8.0.dev20201210+cu101 which is incompatible.\u001b[0m\n",
74+
"Installing collected packages: torch, torchcsprng\n",
75+
" Found existing installation: torch 1.7.0+cu101\n",
76+
" Uninstalling torch-1.7.0+cu101:\n",
77+
" Successfully uninstalled torch-1.7.0+cu101\n",
78+
"Successfully installed torch-1.8.0.dev20201210+cu101 torchcsprng-0.2.0.dev20201210+cu101\n"
79+
],
80+
"name": "stdout"
81+
}
82+
]
4683
},
4784
{
4885
"cell_type": "code",
@@ -53,7 +90,7 @@
5390
"import torch\n",
5491
"import torchcsprng as csprng"
5592
],
56-
"execution_count": null,
93+
"execution_count": 2,
5794
"outputs": []
5895
},
5996
{
@@ -64,7 +101,7 @@
64101
"source": [
65102
"device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')"
66103
],
67-
"execution_count": null,
104+
"execution_count": 3,
68105
"outputs": []
69106
},
70107
{
@@ -79,14 +116,32 @@
79116
{
80117
"cell_type": "code",
81118
"metadata": {
82-
"id": "rw7WYZ-50To9"
119+
"id": "rw7WYZ-50To9",
120+
"outputId": "7e9accec-5ac1-4de2-fcc5-860df06ad338",
121+
"colab": {
122+
"base_uri": "https://localhost:8080/"
123+
}
83124
},
84125
"source": [
85126
"key = torch.empty(16, dtype=torch.uint8, device=device).random_(0, 256)\n",
86127
"key"
87128
],
88-
"execution_count": null,
89-
"outputs": []
129+
"execution_count": 4,
130+
"outputs": [
131+
{
132+
"output_type": "execute_result",
133+
"data": {
134+
"text/plain": [
135+
"tensor([ 94, 155, 111, 73, 36, 65, 95, 175, 103, 249, 39, 221, 225, 106,\n",
136+
" 147, 18], dtype=torch.uint8)"
137+
]
138+
},
139+
"metadata": {
140+
"tags": []
141+
},
142+
"execution_count": 4
143+
}
144+
]
90145
},
91146
{
92147
"cell_type": "markdown",
@@ -109,14 +164,37 @@
109164
{
110165
"cell_type": "code",
111166
"metadata": {
112-
"id": "LcuVmhyU0WTn"
167+
"id": "LcuVmhyU0WTn",
168+
"outputId": "2b887caa-ef4c-4e2a-bc7e-d00191cb727c",
169+
"colab": {
170+
"base_uri": "https://localhost:8080/"
171+
}
113172
},
114173
"source": [
115174
"initial = torch.empty(42, dtype=torch.float32, device=device).normal_(-24.0, 42.0)\n",
116175
"initial"
117176
],
118-
"execution_count": null,
119-
"outputs": []
177+
"execution_count": 5,
178+
"outputs": [
179+
{
180+
"output_type": "execute_result",
181+
"data": {
182+
"text/plain": [
183+
"tensor([ -33.2154, -4.4617, -2.9105, -37.1893, -6.0623, -47.4273,\n",
184+
" -44.7682, 23.7199, 52.3595, -80.1355, 10.7041, -52.0069,\n",
185+
" -59.1335, -51.7051, -96.7531, -47.6263, -37.4668, -26.9140,\n",
186+
" -8.7239, -68.0884, -73.8865, -35.0378, -24.9022, -71.3780,\n",
187+
" -83.3700, -73.9181, -56.9136, -14.0332, -0.1193, -24.6635,\n",
188+
" -12.3755, 26.1501, -21.7292, 61.0362, -8.2424, -27.3287,\n",
189+
" -116.2249, -32.5120, -56.9908, -44.0908, 15.9910, -12.2838])"
190+
]
191+
},
192+
"metadata": {
193+
"tags": []
194+
},
195+
"execution_count": 5
196+
}
197+
]
120198
},
121199
{
122200
"cell_type": "markdown",
@@ -135,7 +213,7 @@
135213
"source": [
136214
"encrypted = torch.empty(22, dtype=torch.int64, device=device)"
137215
],
138-
"execution_count": null,
216+
"execution_count": 6,
139217
"outputs": []
140218
},
141219
{
@@ -150,13 +228,37 @@
150228
{
151229
"cell_type": "code",
152230
"metadata": {
153-
"id": "TK4OjPRq4lsJ"
231+
"id": "TK4OjPRq4lsJ",
232+
"outputId": "a9c7bee0-e95c-49fa-a6a8-8a33b58695e0",
233+
"colab": {
234+
"base_uri": "https://localhost:8080/"
235+
}
154236
},
155237
"source": [
156238
"csprng.encrypt(initial, encrypted, key, \"aes128\", \"ecb\")"
157239
],
158-
"execution_count": null,
159-
"outputs": []
240+
"execution_count": 7,
241+
"outputs": [
242+
{
243+
"output_type": "execute_result",
244+
"data": {
245+
"text/plain": [
246+
"tensor([-1712310488599806515, -8311769289706173237, -8219472943074007291,\n",
247+
" 4944862344658876406, 5289614356287313567, -6556419268017486570,\n",
248+
" -2070634943111059129, -6988005632242749066, -6786984565899259673,\n",
249+
" 2617853683610034142, 7394987086142621793, 9037048344238914391,\n",
250+
" -4389724417591829293, 639143755047053321, 6630155308790632093,\n",
251+
" 8233678956273288167, 7762736707078557167, -66820074992426839,\n",
252+
" 2506358826618882964, 3811127519115226076, 7223286519671228245,\n",
253+
" -4680879586720463643])"
254+
]
255+
},
256+
"metadata": {
257+
"tags": []
258+
},
259+
"execution_count": 7
260+
}
261+
]
160262
},
161263
{
162264
"cell_type": "markdown",
@@ -175,7 +277,7 @@
175277
"source": [
176278
"decrypted = torch.empty_like(initial)"
177279
],
178-
"execution_count": null,
280+
"execution_count": 8,
179281
"outputs": []
180282
},
181283
{
@@ -193,9 +295,9 @@
193295
"id": "kojXCFGK5v6l"
194296
},
195297
"source": [
196-
"csprng.decrypt(encrypted, decrypted, key, \"aes128\", \"ecb\")"
298+
"# csprng.decrypt(encrypted, decrypted, key, \"aes128\", \"ecb\")"
197299
],
198-
"execution_count": null,
300+
"execution_count": 10,
199301
"outputs": []
200302
},
201303
{

0 commit comments

Comments
 (0)