Exemple #1
0
        /// <summary>Encodes a span of UTF-8 text into a span of bytes.</summary>
        /// <returns>The number of the bytes written to <paramref name="base64"/>.</returns>
        public static int Encode(ReadOnlySpan <byte> utf8Data, Span <byte> base64)
        {
            var status = gfoidl.Base64.Base64.Default.Encode(utf8Data, base64, out _, out var bytesWritten);

            if (status != OperationStatus.Done)
            {
                ThrowHelper.ThrowOperationNotDoneException(status);
            }

            return(bytesWritten);
        }
Exemple #2
0
        /// <summary>Decodes the span of UTF-8 base64-encoded text into a span of bytes.</summary>
        /// <returns>The number of the bytes written to <paramref name="data"/>.</returns>
        public static int Decode(ReadOnlySpan <byte> base64, Span <byte> data)
        {
            var status = Decode(base64, data, out _, out int bytesWritten);

            if (status != OperationStatus.Done)
            {
                ThrowHelper.ThrowOperationNotDoneException(status);
            }

            return(bytesWritten);
        }
Exemple #3
0
        /// <summary>
        /// Encodes a span of UTF-8 text into a span of bytes.
        /// </summary>
        /// <returns>The number of the bytes written to <paramref name="base64Url"/>.</returns>
        public static int Encode(ReadOnlySpan <byte> utf8Data, Span <byte> base64Url)
        {
            var status = _base64.TryEncode(utf8Data, base64Url, out _, out var bytesWritten);

            if (status != OperationStatus.Done)
            {
                ThrowHelper.ThrowOperationNotDoneException(status);
            }

            return(bytesWritten);
        }