-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdtbase64.py
More file actions
28 lines (22 loc) · 712 Bytes
/
dtbase64.py
File metadata and controls
28 lines (22 loc) · 712 Bytes
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from base64 import b64encode, b64decode
from dtoperation import DTOperation
class DTBase64(DTOperation):
'''Uses built-in library for base64 encoding and decoding.'''
def needs_key(self):
''''''
return False
def needs_second_key(self):
''''''
return False
def needs_IV(self):
''''''
return False
def transform(self, dt_input, dt_key1=None, dt_key2=None, dt_iv=None, dt_mode='dec'):
'''Return Base64 encoded/decoded output.'''
if dt_mode == 'enc':
return b64encode(dt_input)
elif dt_mode == 'dec':
return b64decode(dt_input)
return None