Exemple #1
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)
Exemple #2
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)