File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+
3+ import re
4+
5+ from Crypto import Random
6+ from Crypto .Cipher import AES
7+
8+ class string (object ):
9+
10+ encrypted_text = '\0 '
11+ __KEY__ = Random .new ().read (32 )
12+ __IV__ = Random .new ().read (16 )
13+
14+ @classmethod
15+ def encrypt (cls ,func ):
16+ def wrapper (* arguments ):
17+ if not re .match ('<__main__.*object at.*>' ,str (arguments [0 ])):
18+ raise SyntaxError ('Method must be an instance method of a class!' )
19+ for string in arguments [1 :]:
20+ key = AES .new (
21+ cls .__KEY__ ,
22+ AES .MODE_CFB ,
23+ cls .__IV__
24+ )
25+ cls .encrypted_text = key .encrypt (string )
26+ return func (arguments [0 ].__class__ ,cls .encrypted_text )
27+ return wrapper
28+
29+ @classmethod
30+ def decrypt (cls ,func ):
31+ def wrapper (* arguments ):
32+ if not re .match ('<__main__.*object at.*>' ,str (arguments [0 ])):
33+ raise SyntaxError ('Method must be an instance method of a class!' )
34+ for string in arguments [1 :]:
35+ key = AES .new (
36+ cls .__KEY__ ,
37+ AES .MODE_CFB ,
38+ cls .__IV__
39+ )
40+ cls .encrypted_text = key .decrypt (string )
41+ return func (arguments [0 ].__class__ ,cls .encrypted_text )
42+ return wrapper
You can’t perform that action at this time.
0 commit comments