< Summary

Class:Azure.Identity.Base64Url
Assembly:Azure.Identity
File(s):C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\Base64Url.cs
Covered lines:0
Uncovered lines:7
Coverable lines:7
Total lines:34
Line coverage:0% (0 of 7)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
Decode(...)-0%0%
Encode(...)-0%100%
HexToBase64Url(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\Base64Url.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Text;
 6
 7namespace Azure.Identity
 8{
 9    internal static class Base64Url
 10    {
 11        public static byte[] Decode(string str)
 12        {
 013            str = new StringBuilder(str).Replace('-', '+').Replace('_', '/').Append('=', (str.Length % 4 == 0) ? 0 : 4 -
 14
 015            return Convert.FromBase64String(str);
 16        }
 17
 18        public static string Encode(byte[] bytes)
 19        {
 020            return new StringBuilder(Convert.ToBase64String(bytes)).Replace('+', '-').Replace('/', '_').Replace("=", "")
 21        }
 22
 23
 24        public static string HexToBase64Url(string hex)
 25        {
 026            byte[] bytes = new byte[hex.Length / 2];
 27
 028            for (int i = 0; i < hex.Length; i += 2)
 029                bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
 30
 031            return Base64Url.Encode(bytes);
 32        }
 33    }
 34}