Skip to content

Commit

Permalink
Move b64enc and b64dec to util.py
Browse files Browse the repository at this point in the history
helper functions related to base64 is now moved to util.py

Signed-off-by: Pradyumna Krishna <[email protected]>
  • Loading branch information
PradyumnaKrishna committed Jun 14, 2022
1 parent a8fbf63 commit ee0ccb6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions securesystemslib/metadata.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Dead Simple Signing Envelope
"""

import base64
from typing import Any, List

from securesystemslib import exceptions
from securesystemslib import formats
from securesystemslib.signer import Signature
from securesystemslib.util import b64dec, b64enc


class Envelope:
Expand Down Expand Up @@ -53,7 +53,8 @@ def from_dict(cls, data: dict) -> "Envelope":
Returns:
A "Envelope" instance.
"""
payload = base64.b64decode(data['payload'].encode())

payload = b64dec(data['payload'])
payloadType = data['payloadType']

signatures = []
Expand All @@ -69,11 +70,11 @@ def from_dict(cls, data: dict) -> "Envelope":

return cls(payload, payloadType, signatures)

def to_dict(self):
def to_dict(self) -> dict:
"""Returns the JSON-serializable dictionary representation of self."""

return {
"payload": base64.b64encode(self.payload).decode(),
"payload": b64enc(self.payload),
"payloadType": self.payloadType,
"signatures": [
signature.to_dict() for signature in self.signatures
Expand Down

0 comments on commit ee0ccb6

Please sign in to comment.