Ejemplo n.º 1
0
        public void EnsureMainMethodWorks()
        {
            string originalEncoded = @"0812561ae6bd42cfb7bee1311a29893508e71c340912e4614f3d9e6c61dccdd5af228051eb4373170A058394b17ac301086ef72ac5367180eb051040d4241e426bbde12bca805f665227e8060234ec07042859ffbc0202b4ed0304bdadb4e00402de60";

            string[] requestedTags = { "0x01", "0x03", "0x04", "0x05", "0x06", "0x0a" };
            string   hash          = BerTlvLogic.GetBase64UrlHashFromEncodedStringForGivenTags(requestedTags, originalEncoded);

            Assert.AreEqual(@"EQ9q1Hjyr_pfSBj1_M2vqAMFH-MYhP2zwhgYfC8u8-g", hash);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            #region Read Data from Config File

            string encodedString = ConfigurationManager.AppSettings[ConfigKeys.EncodedStringKey];
            if (String.IsNullOrWhiteSpace(encodedString))
            {
                Console.WriteLine($"Missing {ConfigKeys.EncodedStringKey} value in ConfigFile. Current Value is: {encodedString}. Press any Key to Exit.");
                Console.ReadKey();
                return;
            }

            string tagIds = ConfigurationManager.AppSettings[ConfigKeys.TagsIdKey];
            if (String.IsNullOrWhiteSpace(tagIds))
            {
                Console.WriteLine($"Missing {ConfigKeys.TagsIdKey} value in ConfigFile. Current Value is: {tagIds}. Press any Key to Exit.");
                Console.ReadKey();
                return;
            }

            string[] requestedTags = tagIds.Split(new char[] { ',' });
            if (requestedTags == null || requestedTags.Length < 1)
            {
                Console.WriteLine($"No tags to extract. TagIds obtained from Config file are: {tagIds}. Press any Key to Exit.");
                Console.ReadKey();
                return;
            }

            #endregion


            #region Get hash from values extracted

            try
            {
                string hash = BerTlvLogic.GetBase64UrlHashFromEncodedStringForGivenTags(requestedTags, encodedString);
                Console.WriteLine($"Extracted hash: {hash} from Encoded String: {encodedString} for tags: {String.Join(",", requestedTags)}. Press any Key to Exit.");
                Console.ReadKey();
                return;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception thrown when trying to Convert String: {encodedString} for tags: {String.Join(",", requestedTags)}. Exception is: {ex.Message}. Press any Key to Exit.");
                Console.ReadKey();
                return;
            }

            #endregion
        }