コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InputVerifyHash" /> class.
        /// </summary>
        /// <param name="input">Original source string (required).</param>
        /// <param name="algorithm">Hash algorithm (required).</param>
        /// <param name="hash">Hashed result (required).</param>
        public InputVerifyHash(string input = default(string), AlgorithmEnum algorithm = default(AlgorithmEnum), string hash = default(string))
        {
            // to ensure "input" is required (not null)
            if (input == null)
            {
                throw new InvalidDataException("input is a required property for InputVerifyHash and cannot be null");
            }
            else
            {
                this.Input = input;
            }

            // to ensure "algorithm" is required (not null)
            if (algorithm == null)
            {
                throw new InvalidDataException("algorithm is a required property for InputVerifyHash and cannot be null");
            }
            else
            {
                this.Algorithm = algorithm;
            }

            // to ensure "hash" is required (not null)
            if (hash == null)
            {
                throw new InvalidDataException("hash is a required property for InputVerifyHash and cannot be null");
            }
            else
            {
                this.Hash = hash;
            }
        }
コード例 #2
0
        public static long GetRateCoeff(this AlgorithmEnum algorithmEnum)
        {
            switch (algorithmEnum)
            {
            case AlgorithmEnum.SHA256:
                return(1000000000000000);

            case AlgorithmEnum.Axiom:
            case AlgorithmEnum.Hodl:
                return(1000);

            case AlgorithmEnum.ScryptJaneNf16:
            case AlgorithmEnum.CryptoNight:
            case AlgorithmEnum.Equihash:
                return(1000000);

            case AlgorithmEnum.ScryptNf:
            case AlgorithmEnum.X13:
            case AlgorithmEnum.X15:
            case AlgorithmEnum.Nist5:
            case AlgorithmEnum.NeoScrypt:
            case AlgorithmEnum.Lyra2RE:
            case AlgorithmEnum.WhirlpoolX:
            case AlgorithmEnum.DaggerHashimoto:
            case AlgorithmEnum.X11Gost:
            case AlgorithmEnum.Skunk:
                return(1000000000);

            default:
                return(1000000000000);
            }
        }
コード例 #3
0
        public NetworkLayoutOptions(
            AlgorithmEnum algorithm,
            float nodeSeparationTarget,
            int iterations,
            float nodeSize,
            float edgeThickness)
        {
            if (nodeSeparationTarget <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (iterations <= 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (nodeSize < 1.0)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (edgeThickness <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.Algorithm            = algorithm;
            this.Iterations           = iterations;
            this.NodeSeparationTarget = nodeSeparationTarget;
            this.NodeSize             = nodeSize;
            this.EdgeThickness        = edgeThickness;
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputVerifyHash" /> class.
 /// </summary>
 /// <param name="input">Original source string (required).</param>
 /// <param name="algorithm">Hash algorithm (required).</param>
 /// <param name="hash">Hashed result (required).</param>
 public InputVerifyHash(string input = default(string), AlgorithmEnum algorithm = default(AlgorithmEnum), string hash = default(string))
 {
     // to ensure "input" is required (not null)
     this.Input     = input ?? throw new ArgumentNullException("input is a required property for InputVerifyHash and cannot be null");
     this.Algorithm = algorithm;
     // to ensure "hash" is required (not null)
     this.Hash = hash ?? throw new ArgumentNullException("hash is a required property for InputVerifyHash and cannot be null");
 }
コード例 #5
0
        private string ToString(AlgorithmEnum algorithm)
        {
            switch (algorithm)
            {
            case AlgorithmEnum.RSA256: return("RS256");

            default: return("RS256");
            }
        }
コード例 #6
0
ファイル: Stego.cs プロジェクト: TheDarkCode/StegoCore
        /// <summary>
        /// Decodes secred data from Image
        /// </summary>
        /// <param name="algorithm">Algorithm used in decoding</param>
        /// <exception cref="System.NullReferenceException">Thrown if the <paramref name="algorithm"/> is is not known algorithm type.</exception>
        /// <exception cref="System.InvalidOperationException">TThrown if the <paramref name="algorithm"/> does not inherit from StegoAlgorithm.</exception>
        /// <exception cref="StegoCore.Exceptions.DecodeException">Thrown if error while decoding occurs</exception>
        /// <returns>Bytes of decoded secred data</returns>
        public byte[] Decode(AlgorithmEnum algorithm)
        {
            if (this.image == null)
            {
                throw new System.NullReferenceException("Image cannot be null");
            }
            var alg = AlgorithmFactory.Create(algorithm);

            return(alg.Decode(this.image, this.settings));
        }
コード例 #7
0
        /// <summary>
        /// Instantiates an SIG RR based on the data in the method's input parameters: the record's DNS Server Name, Container Name, Owner Name, class (default = IN), time-to-live value, and WINS mapping flag, reverse look-up time out, WINS cache time out and domain name to append. It returns a reference to the new object as an output parameter.
        /// </summary>
        /// <param name="server">Server object</param>
        /// <param name="dnsServerName">Fully Qualified Domain Name (FQDN) or IP address of the DNS Server that contains this RR.</param>
        /// <param name="containerName">Name of the Container for the Zone, Cache, or RootHints instance which contains this RR.</param>
        /// <param name="ownerName">Owner FQDN for the RR.</param>
        /// <param name="recordClass">Class of the RR.</param>
        /// <param name="ttl">Time, in seconds, that the RR can be cached by a DNS resolver.</param>
        /// <param name="algorithm">Algorithm used with the key specified in the resource record. </param>
        /// <param name="keyTag">Method used to choose a key that verifies an SIG. See RFC 2535, Appendix C for the method used to calculate a KeyTag.</param>
        /// <param name="labels">Unsigned count of labels in the original SIG RR owner name. The count does not include the NULL label for the root, nor any initial wildcards.</param>
        /// <param name="originalTTL">TTL of the RR set signed by the SIG.</param>
        /// <param name="signature">Signature, represented in base 64, formatted as defined in RFC 2535, Appendix A.</param>
        /// <param name="signatureExpiration">Signature expiration date, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signatureInception">Date and time at which the Signature becomes valid, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signerName">Domain name of the signer that generated the SIG RR.</param>
        /// <param name="typeCovered">Type of RR covered by this SIG.</param>
        /// <returns>the new object.</returns>
        public static SIGType CreateInstanceFromPropertyData(
            Server server,
            string dnsServerName,
            string containerName,
            string ownerName,
            RecordClassEnum?recordClass,
            TimeSpan?ttl,
            UInt16 typeCovered,
            AlgorithmEnum algorithm,
            UInt16 labels,
            TimeSpan originalTTL,
            UnixDateTime signatureExpiration,
            UnixDateTime signatureInception,
            UInt16 keyTag,
            string signerName,
            string signature)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server is required");
            }

            ManagementClass      dnsClass = new ManagementClass(server.m_scope, new ManagementPath("MicrosoftDNS_SIGType"), null);
            ManagementBaseObject inParams = dnsClass.GetMethodParameters("CreateInstanceFromPropertyData");

            inParams["DnsServerName"] = dnsServerName;
            inParams["ContainerName"] = containerName;
            inParams["OwnerName"]     = ownerName;
            if (recordClass != null)
            {
                inParams["RecordClass"] = (UInt32)recordClass.Value;
            }
            if (ttl != null)
            {
                inParams["TTL"] = ttl.Value.TotalSeconds;
            }
            inParams["Algorithm"]           = (UInt16)algorithm;
            inParams["Labels"]              = labels;
            inParams["OriginalTTL"]         = originalTTL.TotalSeconds;
            inParams["SignatureExpiration"] = signatureExpiration.Unix;
            inParams["SignatureInception"]  = signatureInception.Unix;
            inParams["KeyTag"]              = keyTag;
            inParams["SignerName"]          = signerName;
            inParams["Signature"]           = signature;

            //return new SIGType((ManagementObject)dnsClass.InvokeMethod("CreateInstanceFromPropertyData", inParams, null));
            try
            {
                return(new SIGType(new ManagementObject(server.m_scope, new ManagementPath(dnsClass.InvokeMethod("CreateInstanceFromPropertyData", inParams, null)["RR"].ToString()), null)));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #8
0
        public async Task <IActionResult> Embed(IFormFile secret, AlgorithmEnum algorithm, string format)
        {
            EmbedResult result;

            try {
                result = await _stegoModel.Embed(secret, algorithm, format, HttpContext.Session);
            }
            catch (Exception e) {
                return(Content($"Error while embending: {e.Message}"));
            }
            return(View(result));
        }
コード例 #9
0
ファイル: Stego.cs プロジェクト: TheDarkCode/StegoCore
        /// <summary>
        /// Embed secret data in Image
        /// </summary>
        /// <param name="algorithm">Algorithm used in embending</param>
        /// <exception cref="System.NullReferenceException">Thrown if the <paramref name="algorithm"/> is is not known algorithm type.</exception>
        /// <exception cref="System.InvalidOperationException">TThrown if the <paramref name="algorithm"/> does not inherit from StegoAlgorithm.</exception>
        /// <exception cref="StegoCore.Exceptions.DataToBigException">Thrown if the secred data is to big for embending</exception>
        /// <returns>Image with embeded secret data</returns>
        public Image <Rgba32> Embed(AlgorithmEnum algorithm)
        {
            if (this.image == null)
            {
                throw new System.NullReferenceException("Image cannot be null");
            }
            if (this.secretData == null)
            {
                throw new System.NullReferenceException("Secret data cannot be null");
            }
            var alg = AlgorithmFactory.Create(algorithm);

            return(alg.Embed(this.image, this.secretData, this.settings));
        }
コード例 #10
0
        public IActionResult Decrypt(string id, AlgorithmEnum algorithm)
        {
            var userImage = HttpContext.Session.Get <UserImage>(nameof(UserImage));
            var filePath  = Path.Combine(_stegoModel.GetUploadsPath(), id);

            if (System.IO.File.Exists(filePath) && (userImage.Guid == id || userImage.EmbededGuid == id))
            {
                using (var stego = new Stego(filePath))
                {
                    var result = stego.Decode(algorithm);
                    return(File(result, "application/octet-stream", "secret"));
                }
            }
            return(Content("Wrong id"));
        }
コード例 #11
0
        public static StegoAlgorithm Create(AlgorithmEnum selection)
        {
            var type = Type.GetType(typeof(StegoAlgorithm).Namespace + "." + selection.ToString(), throwOnError: false);

            if (type == null)
            {
                throw new NullReferenceException(selection.ToString() + " is not a known algorithm type");
            }

            if (!typeof(StegoAlgorithm).IsAssignableFrom(type))
            {
                throw new InvalidOperationException(type.Name + " does not inherit from StegoAlghorithm");
            }

            return((StegoAlgorithm)Activator.CreateInstance(type));
        }
コード例 #12
0
        private void Encrypt_Decrypt(AlgorithmEnum alg, IImageFormat imageFormat, string outFileName)
        {
            Configuration.Default.AddImageFormat(imageFormat);

            var algorithm = AlgorithmFactory.Create(alg);

            byte[] secretDataBytes = System.IO.File.ReadAllBytes(FileHelper.GetPathToSecretData());

            var notSavedStego = EncryptAndSave(algorithm, secretDataBytes, outFileName);

            var stegoImage = Image.Load(outFileName);

            byte[] resultSecret = algorithm.Decode(notSavedStego, null);

            Assert.Equal(secretDataBytes, resultSecret);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: stephenreynolds/checkcheck
        static void CompareHash(string filePath, string hash, AlgorithmEnum algorithm)
        {
            string fileHash = ComputeHash(filePath, algorithm);

            // Make sure file hash was computed successfully and compare with given hash.
            if (fileHash == null)
            {
                Console.WriteLine("Invalid hashing algorithm given. Valid options are: MD5, SHA1, SHA256, SHA384, and SHA512.");
            }
            else if (fileHash == hash)
            {
                Console.WriteLine($"{Path.GetFileName(filePath)} validated succcessfully.");
            }
            else
            {
                Console.WriteLine($"{algorithm.ToString()} validation FAILED!");
                Console.WriteLine($"File hash is: \t\t\t{fileHash}\nBut the hash given was: \t{hash}");
            }
        }
コード例 #14
0
        public async Task <EmbedResult> Embed(IFormFile secret, AlgorithmEnum algorithm, string format, ISession session)
        {
            var userImage   = session.Get <UserImage>(nameof(UserImage));
            var filePath    = Path.Combine(GetUploadsPath(), userImage.Guid);
            var embedResult = new EmbedResult
            {
                Algorithm = algorithm,
                Success   = false
            };

            if (secret != null && secret.Length > 0 && System.IO.File.Exists(filePath))
            {
                byte[] secretBytes = null;
                using (var memoryStrem = new MemoryStream())
                {
                    await secret.CopyToAsync(memoryStrem);

                    secretBytes = memoryStrem.ToArray();
                }
                using (var stego = new Stego(filePath))
                {
                    stego.SetSecretData(secretBytes);
                    var imageWithSecret = stego.Embed(algorithm);
                    var formatType      = Helpers.FormatHelper.GetEncoderByName(format);
                    if (formatType is SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder)
                    {
                        (formatType as SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder).Quality = 100;
                    }
                    imageWithSecret.Save(Path.Combine(GetUploadsPath(), embedResult.Guid), formatType);
                    embedResult.Success   = true;
                    embedResult.Format    = userImage.EmbededFormat = format;
                    userImage.EmbededGuid = embedResult.Guid;
                }
                session.Set <UserImage>(nameof(UserImage), userImage);
            }
            else
            {
                throw new InvalidDataException("You have to select secret file to embed in image");
            }
            return(embedResult);
        }
コード例 #15
0
ファイル: Program.cs プロジェクト: stephenreynolds/checkcheck
        static string ComputeHash(string filePath, AlgorithmEnum algorithm)
        {
            // Read the file.
            using (var stream = new BufferedStream(File.OpenRead(filePath), 1200000))
            {
                HashAlgorithm hashAlgorithm;

                switch (algorithm)
                {
                case AlgorithmEnum.MD5:
                    hashAlgorithm = MD5.Create();
                    break;

                case AlgorithmEnum.SHA1:
                    hashAlgorithm = new SHA1Managed();
                    break;

                case AlgorithmEnum.SHA256:
                    hashAlgorithm = new SHA256Managed();
                    break;

                case AlgorithmEnum.SHA384:
                    hashAlgorithm = new SHA384Managed();
                    break;

                case AlgorithmEnum.SHA512:
                    hashAlgorithm = new SHA512Managed();
                    break;

                default:
                    return(null);
                }

                byte[] fileHash = hashAlgorithm.ComputeHash(stream);
                return(BitConverter.ToString(fileHash).Replace("-", string.Empty));
            }
        }
コード例 #16
0
        /// <summary>
        /// Updates the TTL, Mapping Flag, Look-up Time out, Cache Time out and Result Domain to the values specified as the input parameters of this method. If a new value for a parameter is not specified, then the current value for the parameter is not changed. The method returns a reference to the modified object as an output parameter.
        /// </summary>
        /// <param name="ttl">Optional - Time, in seconds, that the RR can be cached by a DNS resolver.</param>
        /// <param name="algorithm">Algorithm used with the key specified in the resource record. </param>
        /// <param name="keyTag">Method used to choose a key that verifies an SIG. See RFC 2535, Appendix C for the method used to calculate a KeyTag.</param>
        /// <param name="labels">Unsigned count of labels in the original SIG RR owner name. The count does not include the NULL label for the root, nor any initial wildcards.</param>
        /// <param name="originalTTL">TTL of the RR set signed by the SIG.</param>
        /// <param name="signature">Signature, represented in base 64, formatted as defined in RFC 2535, Appendix A.</param>
        /// <param name="signatureExpiration">Signature expiration date, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signatureInception">Date and time at which the Signature becomes valid, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signerName">Domain name of the signer that generated the SIG RR.</param>
        /// <param name="typeCovered">Type of RR covered by this SIG.</param>
        /// <returns>the modified object.</returns>
        public SIGType Modify(TimeSpan?ttl, UInt16 typeCovered,
                              AlgorithmEnum algorithm,
                              UInt16 labels,
                              TimeSpan originalTTL,
                              UnixDateTime signatureExpiration,
                              UnixDateTime signatureInception,
                              UInt16 keyTag,
                              string signerName,
                              string signature)
        {
            ManagementBaseObject inParams = m_mo.GetMethodParameters("Modify");

            if ((ttl != null) && (ttl != this.TTL))
            {
                inParams["TTL"] = ttl.Value.TotalSeconds;
            }

            //these are not optional, need to check if record is deleted if the same
            inParams["Algorithm"]           = (UInt16)algorithm;
            inParams["Labels"]              = labels;
            inParams["OriginalTTL"]         = originalTTL.TotalSeconds;
            inParams["SignatureExpiration"] = signatureExpiration.Unix;
            inParams["SignatureInception"]  = signatureInception.Unix;
            inParams["KeyTag"]              = keyTag;
            inParams["SignerName"]          = signerName;
            inParams["Signature"]           = signature;

            //return new SIGType((ManagementObject)m_mo.InvokeMethod("Modify", inParams, null));
            try
            {
                return(new SIGType(new ManagementObject(m_mo.Scope, new ManagementPath(m_mo.InvokeMethod("Modify", inParams, null)["RR"].ToString()), null)));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #17
0
ファイル: !Model.cs プロジェクト: duckmaestro/F-AI
        public NetworkLayoutOptions(
            AlgorithmEnum algorithm,
            float nodeSeparationTarget,
            int iterations,
            float nodeSize,
            float edgeThickness)
        {
            if (nodeSeparationTarget <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (iterations <= 1)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (nodeSize < 1.0)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (edgeThickness <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            this.Algorithm = algorithm;
            this.Iterations = iterations;
            this.NodeSeparationTarget = nodeSeparationTarget;
            this.NodeSize = nodeSize;
            this.EdgeThickness = edgeThickness;
        }
コード例 #18
0
 public static Color[,] Compute(Color[,] bitmap, AlgorithmEnum dithering)
 {
     return(new Color[1, 1]);
 }
コード例 #19
0
 private void radioButton5_Click(object sender, EventArgs e)
 {
     algorithm = AlgorithmEnum.ditheringBurkes;
 }
コード例 #20
0
        public string GetTreatment(string key, int seed, List <PartitionDefinition> partitions, AlgorithmEnum algorithm)
        {
            if (String.IsNullOrEmpty(key))
            {
                return(Control);
            }

            if (partitions.Count() == 1 && partitions.First().size == 100)
            {
                return(partitions.First().treatment);
            }

            var bucket = algorithm == AlgorithmEnum.LegacyHash ? LegacyBucket(key, seed) : Bucket(key, seed);

            var covered = 0;

            foreach (PartitionDefinition partition in partitions)
            {
                covered += partition.size;
                if (covered >= bucket)
                {
                    return(partition.treatment);
                }
            }

            return(Control);
        }
コード例 #21
0
 private void radioButton6_Click(object sender, EventArgs e)
 {
     algorithm = AlgorithmEnum.ditheringStucky;
 }
コード例 #22
0
ファイル: SIGType.cs プロジェクト: drorgl/MSDNSWebAdmin
        /// <summary>
        /// Instantiates an SIG RR based on the data in the method's input parameters: the record's DNS Server Name, Container Name, Owner Name, class (default = IN), time-to-live value, and WINS mapping flag, reverse look-up time out, WINS cache time out and domain name to append. It returns a reference to the new object as an output parameter. 
        /// </summary>
        /// <param name="server">Server object</param>
        /// <param name="dnsServerName">Fully Qualified Domain Name (FQDN) or IP address of the DNS Server that contains this RR.</param>
        /// <param name="containerName">Name of the Container for the Zone, Cache, or RootHints instance which contains this RR.</param>
        /// <param name="ownerName">Owner FQDN for the RR.</param>
        /// <param name="recordClass">Class of the RR.</param>
        /// <param name="ttl">Time, in seconds, that the RR can be cached by a DNS resolver.</param>
        /// <param name="algorithm">Algorithm used with the key specified in the resource record. </param>
        /// <param name="keyTag">Method used to choose a key that verifies an SIG. See RFC 2535, Appendix C for the method used to calculate a KeyTag.</param>
        /// <param name="labels">Unsigned count of labels in the original SIG RR owner name. The count does not include the NULL label for the root, nor any initial wildcards.</param>
        /// <param name="originalTTL">TTL of the RR set signed by the SIG.</param>
        /// <param name="signature">Signature, represented in base 64, formatted as defined in RFC 2535, Appendix A.</param>
        /// <param name="signatureExpiration">Signature expiration date, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signatureInception">Date and time at which the Signature becomes valid, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signerName">Domain name of the signer that generated the SIG RR.</param>
        /// <param name="typeCovered">Type of RR covered by this SIG.</param>
        /// <returns>the new object.</returns>
        public static SIGType CreateInstanceFromPropertyData(
            Server server,
            string dnsServerName,
            string containerName,
            string ownerName,
            RecordClassEnum? recordClass,
            TimeSpan? ttl,
             UInt16 typeCovered,
             AlgorithmEnum algorithm,
             UInt16 labels,
             TimeSpan originalTTL,
             UnixDateTime signatureExpiration,
             UnixDateTime signatureInception,
             UInt16 keyTag,
             string signerName,
             string signature)
        {
            if (server == null)
                throw new ArgumentNullException("server is required");

            ManagementClass dnsClass = new ManagementClass(server.m_scope, new ManagementPath("MicrosoftDNS_SIGType"), null);
            ManagementBaseObject inParams = dnsClass.GetMethodParameters("CreateInstanceFromPropertyData");
            inParams["DnsServerName"] = dnsServerName;
            inParams["ContainerName"] = containerName;
            inParams["OwnerName"] = ownerName;
            if (recordClass != null)
                inParams["RecordClass"] = (UInt32)recordClass.Value;
            if (ttl != null)
                inParams["TTL"] = ttl.Value.TotalSeconds;
            inParams["Algorithm"] = (UInt16)algorithm;
            inParams["Labels"] = labels;
            inParams["OriginalTTL"] = originalTTL.TotalSeconds;
            inParams["SignatureExpiration"] = signatureExpiration.Unix;
            inParams["SignatureInception"] = signatureInception.Unix;
            inParams["KeyTag"] = keyTag;
            inParams["SignerName"] = signerName;
            inParams["Signature"] = signature;

            //return new SIGType((ManagementObject)dnsClass.InvokeMethod("CreateInstanceFromPropertyData", inParams, null));
            try
            {
                return new SIGType(new ManagementObject(server.m_scope, new ManagementPath(dnsClass.InvokeMethod("CreateInstanceFromPropertyData", inParams, null)["RR"].ToString()), null));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #23
0
ファイル: SIGType.cs プロジェクト: drorgl/MSDNSWebAdmin
        /// <summary>
        /// Updates the TTL, Mapping Flag, Look-up Time out, Cache Time out and Result Domain to the values specified as the input parameters of this method. If a new value for a parameter is not specified, then the current value for the parameter is not changed. The method returns a reference to the modified object as an output parameter. 
        /// </summary>
        /// <param name="ttl">Optional - Time, in seconds, that the RR can be cached by a DNS resolver.</param>
        /// <param name="algorithm">Algorithm used with the key specified in the resource record. </param>
        /// <param name="keyTag">Method used to choose a key that verifies an SIG. See RFC 2535, Appendix C for the method used to calculate a KeyTag.</param>
        /// <param name="labels">Unsigned count of labels in the original SIG RR owner name. The count does not include the NULL label for the root, nor any initial wildcards.</param>
        /// <param name="originalTTL">TTL of the RR set signed by the SIG.</param>
        /// <param name="signature">Signature, represented in base 64, formatted as defined in RFC 2535, Appendix A.</param>
        /// <param name="signatureExpiration">Signature expiration date, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signatureInception">Date and time at which the Signature becomes valid, expressed in seconds since the beginning of January 1, 1970, Greenwich Mean Time (GMT), excluding leap seconds.</param>
        /// <param name="signerName">Domain name of the signer that generated the SIG RR.</param>
        /// <param name="typeCovered">Type of RR covered by this SIG.</param>
        /// <returns>the modified object.</returns>
        public SIGType Modify(TimeSpan? ttl, UInt16 typeCovered,
             AlgorithmEnum algorithm,
             UInt16 labels,
             TimeSpan originalTTL,
             UnixDateTime signatureExpiration,
             UnixDateTime signatureInception,
             UInt16 keyTag,
             string signerName,
             string signature)
        {
            ManagementBaseObject inParams = m_mo.GetMethodParameters("Modify");
            if ((ttl != null) && (ttl != this.TTL))
                inParams["TTL"] = ttl.Value.TotalSeconds;

            //these are not optional, need to check if record is deleted if the same
            inParams["Algorithm"] = (UInt16)algorithm;
            inParams["Labels"] = labels;
            inParams["OriginalTTL"] = originalTTL.TotalSeconds;
            inParams["SignatureExpiration"] = signatureExpiration.Unix;
            inParams["SignatureInception"] = signatureInception.Unix;
            inParams["KeyTag"] = keyTag;
            inParams["SignerName"] = signerName;
            inParams["Signature"] = signature;

            //return new SIGType((ManagementObject)m_mo.InvokeMethod("Modify", inParams, null));
            try
            {

                return new SIGType(new ManagementObject(m_mo.Scope, new ManagementPath(m_mo.InvokeMethod("Modify", inParams, null)["RR"].ToString()), null));
            }
            catch (ManagementException me)
            {
                throw new WMIException(me);
            }
        }
コード例 #24
0
 private void radioButton7_Click(object sender, EventArgs e)
 {
     algorithm = AlgorithmEnum.popularityAlgorythm;
 }
コード例 #25
0
 private void radioButton4_Click(object sender, EventArgs e)
 {
     algorithm = AlgorithmEnum.ditheringFloydSteinberg;
 }
コード例 #26
0
 public int GetBucket(string key, int seed, AlgorithmEnum algorithm)
 {
     return(algorithm == AlgorithmEnum.LegacyHash
         ? LegacyBucket(key, seed)
         : Bucket(key, seed));
 }
コード例 #27
0
 public void ExecuteStrategy(AlgorithmEnum algorithmEnum)
 {
     _strategy.TryGetValue(algorithmEnum, out IStrategy strategy);
     strategy.ExecuteAlgorithm();
 }
コード例 #28
0
        public static string GetDescription(this AlgorithmEnum val)
        {
            var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
        }
コード例 #29
0
        /// <summary>
        /// Sets which algorithm to use and sets up model if nodes exist
        /// </summary>
        /// <param name="selection">The algorithm to use</param>
        public void SetAlgorithm(AlgorithmEnum selection)
        {
            switch (selection)
            {
                case AlgorithmEnum.BruteForce:
                    algorithm = new BruteForce();
                    break;
                case AlgorithmEnum.GrahamScan:
                    algorithm = new GrahamScan();
                    break;
                default:
                    throw new NotImplementedException("There is no algorithm that matches that selection");
            }

            if (model.GetNodeList().Count > 0)
            {
                ScaleStepTrackBar();
            }
        }
コード例 #30
0
 private void radioButton1_Click(object sender, EventArgs e)
 {
     algorithm = AlgorithmEnum.ditheringAverage;
 }
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InputGenerateHash" /> class.
 /// </summary>
 /// <param name="input">Hash source string (required).</param>
 /// <param name="algorithm">Hash algorithm (required).</param>
 public InputGenerateHash(string input = default(string), AlgorithmEnum algorithm = default(AlgorithmEnum))
 {
     // to ensure "input" is required (not null)
     this.Input     = input ?? throw new ArgumentNullException("input is a required property for InputGenerateHash and cannot be null");
     this.Algorithm = algorithm;
 }
コード例 #32
0
 private void radioButton3_Click(object sender, EventArgs e)
 {
     algorithm = AlgorithmEnum.ditheringOrderedVersion2;
 }