Exemplo n.º 1
0
        static IEnumerable<string> getFiles(IConfigSectionNode configRoot)
        {
            var pathArg = configRoot.AttrByIndex(0).Value;
                                      if (!Path.IsPathRooted(pathArg)) pathArg = "."+Path.DirectorySeparatorChar + pathArg;
                                      var rootPath = Path.GetDirectoryName(pathArg);
                                      var mask = Path.GetFileName(pathArg);
                                      if (mask.Length == 0) mask = "*";

                                      return rootPath.AllFileNamesThatMatch(mask, configRoot["r"].Exists || configRoot["recurse"].Exists);
        }
Exemplo n.º 2
0
        static IEnumerable <string> getFiles(IConfigSectionNode configRoot)
        {
            var pathArg = configRoot.AttrByIndex(0).Value;

            if (!Path.IsPathRooted(pathArg))
            {
                pathArg = "." + Path.DirectorySeparatorChar + pathArg;
            }
            var rootPath = Path.GetDirectoryName(pathArg);
            var mask     = Path.GetFileName(pathArg);

            if (mask.Length == 0)
            {
                mask = "*";
            }

            return(rootPath.AllFileNamesThatMatch(mask, configRoot["r"].Exists || configRoot["recurse"].Exists));
        }
Exemplo n.º 3
0
        private static void doKey(IApplication app, IConfigSectionNode keySwitch)
        {
            var bitLength = keySwitch.AttrByIndex(0).ValueAsInt(256);

            if (bitLength < 8 || bitLength % 8 != 0)
            {
                ConsoleUtils.Error("Invalid key bit length: {0}; would use 256 bits instead".Args(bitLength));
                bitLength = 256;
            }

            var count = bitLength / 8;

            ConsoleUtils.Info("Key of {0} bits/{1} bytes is generated".Args(bitLength, count));

            var key = app.SecurityManager.Cryptography.GenerateRandomBytes(count);

            Console.WriteLine("As BASE64: \"base64:{0}\"".Args(key.ToWebSafeBase64()));
            Console.WriteLine("As HEX: \"{0}\"".Args(string.Join(",", key.Select(b => b.ToString("X2")))));
        }