Skip to content

Commit 76fdfdb

Browse files
committed
Initial commit of Base64Encoder processor
1 parent a84e69e commit 76fdfdb

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

SharedProcessors/Base64Encoder.py

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/local/autopkg/python
2+
# -*- coding: utf-8 -*-
3+
#
4+
# Copyright 2024 Nathan Felton (n8felton)
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
"""Base64 encode a given input to printable ASCII characters as specified in RFC 4648"""
18+
19+
import base64
20+
21+
from autopkglib import Processor
22+
23+
__all__ = ["Base64Encoder"]
24+
25+
26+
class Base64Encoder(Processor):
27+
"""Base64 encode a given input to printable ASCII characters"""
28+
29+
description = __doc__
30+
input_variables = {
31+
"input": {
32+
"required": True,
33+
"description": "The input to be Base64 encoded.",
34+
},
35+
}
36+
output_variables = {
37+
"base64": {"description": "Base64 encoding of the input."},
38+
}
39+
40+
def main(self):
41+
self.env["base64"] = base64.b64encode(
42+
self.env.get("input").encode("ascii")
43+
).decode("ascii")
44+
45+
46+
if __name__ == "__main__":
47+
PROCESSOR = Base64Encoder()
48+
PROCESSOR.execute_shell()

0 commit comments

Comments
 (0)