-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #5
- Loading branch information
Showing
2 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,81 @@ | ||
# base64 Module - encoding and decoding base64 encoded values | ||
import base64 | ||
|
||
class h2r_base64(): | ||
"""docstring for .""" | ||
|
||
def __init__(self, parent): | ||
# super(, self).__init__() | ||
self.parent = parent | ||
|
||
# | ||
# Register Encoders | ||
# | ||
|
||
b64 = "03:self.h2r_base64.base64_encode" | ||
if b64 not in self.parent.encoders: | ||
self.parent.encoders[b64] = {} | ||
self.parent.encoders[b64]["robottranscode"] = "self.h2r_base64.base64_decode" | ||
|
||
# | ||
# Register Decoders | ||
# | ||
|
||
b64 = "03:self.h2r_base64.base64_decode" | ||
if b64 not in self.parent.encoders: | ||
self.parent.decoders[b64] = {} | ||
self.parent.decoders[b64]["robottranscode"] = "self.h2r_base64.base64_encode" | ||
|
||
# | ||
# Register Paersers | ||
# | ||
|
||
# | ||
# Register processors | ||
# | ||
|
||
|
||
# | ||
# Encoders | ||
# | ||
|
||
def base64_encode(self, s): | ||
try: | ||
s_bytes = s.encode('utf_8') | ||
base64_bytes = base64.b64encode(s_bytes) | ||
base64_s = base64_bytes.decode('utf_8') | ||
return base64_s | ||
except Exception: | ||
return s | ||
|
||
# | ||
# Decoders | ||
# | ||
|
||
def base64_decode(self, s): | ||
try: | ||
# s_bytes = s.encode('utf_8') | ||
s_bytes = s.encode() | ||
dec_bytes = base64.b64decode(s_bytes) | ||
# dec_s = dec_bytes.decode('utf_8') | ||
dec_s = dec_bytes.decode() | ||
return dec_s | ||
except Exception: | ||
return s | ||
|
||
|
||
# | ||
# Paersers | ||
# | ||
|
||
|
||
|
||
# | ||
# processors | ||
# | ||
|
||
|
||
|
||
|
||
|
||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters