static public string generateCredValueJson(string schemaAttributes, string credValues)
        {
            JArray attributes = JArray.Parse(schemaAttributes);

            JArray values = JArray.Parse(credValues);

            if (attributes.Count != values.Count)
            {
                Console.WriteLine("Number of arguments is not the same!");
            }

            string output = "{";

            for (int idx = 0; idx < values.Count; ++idx)
            {
                string encoding = values[idx].ToString();
                if (!StringFacilitator.IsDigitsOnly(values[idx].ToString()))
                {
                    encoding = sha256_hash(values[idx].ToString());
                    encoding = hexToDec(encoding);
                }
                output += "\"" + attributes[idx].ToString() + "\": {\"raw\": \"";
                output += values[idx].ToString() + "\", \"encoded\": \"" + encoding + "\"}";

                if (idx != values.Count - 1)
                {
                    output += ",";
                }
            }

            output += "}";

            return(output);
        }
Ejemplo n.º 2
0
        private int stringToIntParser(string input)
        {
            if (!StringFacilitator.IsDigitsOnly(input))
            {
                throw new InvalidDataException("This value may only contain numbers");
            }

            return(Int32.Parse(input));
        }