コード例 #1
0
        /// <summary>
        /// Creates a clone of this BioInspiredKey object.
        /// </summary>
        /// <returns>
        /// A new BioInspiredKey object whose values are
        /// copied from the calling object.
        /// </returns>
        public BioInspiredKey Clone()
        {
            BioInspiredKey clone = new BioInspiredKey(
                mu1, x01, mu2, x02, mu3, x03, mu4, x04, SecretImage);

            return(clone);
        }
コード例 #2
0
        /// <summary>
        /// Generates a new random key that is within the valid keyspace
        /// with a randomly generated secret image.
        /// </summary>
        /// <param name="secretImageWidth">
        /// The width in pixels for the generated secret image.
        /// </param>
        /// <param name="secretImageHeight">
        /// The height in pixels for the generated secret image.
        /// </param>
        /// <returns>
        /// A new BioInspiredKey object whose values are within the
        /// correct logistic map keyspace for chaos and a randomly
        /// generated secret image.
        /// </returns>
        public static BioInspiredKey Generate(
            int secretImageWidth, int secretImageHeight)
        {
            BioInspiredKey newKey = Generate();

            newKey.SecretImage = ImageEncryption.GenerateSecretImage(
                secretImageWidth, secretImageHeight);

            return(newKey);
        }
コード例 #3
0
        /// <summary>
        /// Generates a new random key that is within the valid keyspace.
        /// </summary>
        /// <returns>
        /// A new BioInspiredKey object whose values are within the
        /// correct logistic map keyspace.
        /// </returns>
        public static BioInspiredKey Generate()
        {
            Random rand = new Random();

            double scalar = (4.0 - 3.569955672);

            BioInspiredKey newKey = new BioInspiredKey(
                (scalar * rand.NextDouble()) + 3.569955672,  // mu1
                rand.NextDouble(),                           // x01
                (scalar * rand.NextDouble()) + 3.569955672,  // mu2
                rand.NextDouble(),                           // x02
                (scalar * rand.NextDouble()) + 3.569955672,  // mu3
                rand.NextDouble(),                           // x03
                (scalar * rand.NextDouble()) + 3.569955672,  // mu4
                rand.NextDouble());                          // x04

            return(newKey);
        }
コード例 #4
0
 /// <summary>
 /// Full initialization constructor.
 /// </summary>
 /// <param name="plaintextImage">
 /// The image that is to be encrypted.
 /// </param>
 /// <param name="key">
 /// The BioInspiredKey object that is used to encrypt the image.
 /// </param>
 public BioInspiredEncryptor(Bitmap plaintextImage, BioInspiredKey key)
 {
     PlaintextImage = (Bitmap)plaintextImage.Clone();
     Key            = key.Clone();
 }
コード例 #5
0
 /// <summary>
 /// Basic initialization constructor with a predefined plaintext image.
 /// </summary>
 /// <param name="plaintextImage">
 /// The image that will be encrypted once a key is defined.
 /// </param>
 public BioInspiredEncryptor(Bitmap plaintextImage)
     : this(plaintextImage, BioInspiredKey.Generate())
 {
 }
コード例 #6
0
 /// <summary>
 /// Basic constructor with a predefined key.
 /// </summary>
 /// <param name="key">
 /// The BioInspiredKey object that will be used by the cryptosystem.
 /// </param>
 public BioInspiredEncryptor(BioInspiredKey key)
     : this(null, key)
 {
 }