示例#1
0
    def decode(encoded):
        """
        Decodes a base64 encoded string.

        :param encoded: base64 encoded string
        :param alphabet: alphabet to use in the decoding
        :return: decoded value
        """

        return BaseCodec.decode(encoded, ALPHABET)
示例#2
0
    def encode(value):
        """
        Encodes the given value in base64.

        :param value: value to encode
        :param alphabet: alphabet to use in the encoding
        :return: base64 encoded string
        """

        return BaseCodec.encode(value, ALPHABET, bs=3)
示例#3
0
    def decode(encoded, alphabet=Base62Alphabet.NLU):
        """
        Decodes a base62 encoded string.

        :param encoded: base62 encoded string
        :param alphabet: alphabet to use in the decoding
        :return: decoded value
        """

        if len(alphabet) != 62:
            raise Exception('Invalid alphabet')

        return BaseCodec.decode(encoded, alphabet)
示例#4
0
    def encode(num, alphabet=Base62Alphabet.NLU):
        """
        Encodes the given phrase in base62.

        :param data: value to encode
        :param alphabet: alphabet to use in the encoding
        :return: base62 encoded string
        """

        if len(alphabet) != 62:
            raise Exception('Invalid alphabet')

        return BaseCodec.encode(num, alphabet)