MCPcopy Create free account
hub / github.com/StackStorm/st2 / Base64WSEncode

Function Base64WSEncode

st2common/st2common/util/crypto.py:441–460  ·  view source on GitHub ↗

Return Base64 web safe encoding of s. Suppress padding characters (=). Uses URL-safe alphabet: - replaces +, _ replaces /. Will convert s of type unicode to string type first. @param s: string to encode as Base64 @type s: string @return: Base64 representation of s. @r

(s)

Source from the content-addressed store, hash-verified

439
440
441def Base64WSEncode(s):
442 """
443 Return Base64 web safe encoding of s. Suppress padding characters (=).
444
445 Uses URL-safe alphabet: - replaces +, _ replaces /. Will convert s of type
446 unicode to string type first.
447
448 @param s: string to encode as Base64
449 @type s: string
450
451 @return: Base64 representation of s.
452 @rtype: string
453
454 NOTE: Taken from keyczar (Apache 2.0 license)
455 """
456 if isinstance(s, six.text_type):
457 # Make sure input string is always converted to bytes (if not already)
458 s = s.encode("utf-8")
459
460 return base64.urlsafe_b64encode(s).decode("utf-8").replace("=", "")
461
462
463def Base64WSDecode(s):

Callers 1

generateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected