Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
37 lines (30 loc) · 1.04 KB

File metadata and controls

37 lines (30 loc) · 1.04 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright 2018 Google LLC
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.
import Cryptodome.Cipher.AES
import cipher
class AES(cipher.Blockcipher):
def set_keylen(self, k):
self.choose_variant(lambda v: v["lengths"]["key"] == k)
def variant_name(self):
l = self.lengths()
return "{}{}".format(self.name(), l['key'] * 8)
def variants(self):
for kl in [16, 24, 32]:
yield {
'cipher': 'AES',
'lengths': {
'block': 16,
'key': kl
}
}
def encrypt(self, pt, key):
assert len(key) == self.lengths()['key']
a = Cryptodome.Cipher.AES.new(key, Cryptodome.Cipher.AES.MODE_ECB)
return a.encrypt(pt)
def decrypt(self, ct, key):
assert len(key) == self.lengths()['key']
a = Cryptodome.Cipher.AES.new(key, Cryptodome.Cipher.AES.MODE_ECB)
return a.decrypt(ct)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.