Esempio n. 1
0
        public EncryptionKey(string password, DateTime date)
        {
            EncryptionValues aux = new EncryptionValues();

            aux.password_ = password;
            aux.date_     = date;
            generateKey(aux);
        }
Esempio n. 2
0
        public EncryptionKey(string password, DateTime date, bool localmachine)
        {
            EncryptionValues aux = new EncryptionValues();

            aux.password_ = password;
            aux.date_     = date;

            if (localmachine)
            {
                aux.localMachine_ = System.Environment.MachineName;
            }
            else
            {
                aux.localMachine_ = null;
            }

            generateKey(aux);
        }
Esempio n. 3
0
        //Genera la clave con los valores obtenidos
        private void generateKey(EncryptionValues values)
        {
            Int64 auxInt = 0;

            //Password
            for (int i = 0; i < values.password_.Length; i++)
            {
                auxInt += (values.password_[i] * i);
                if (auxInt >= int.MaxValue)
                {
                    auxInt = auxInt % int.MaxValue;
                }
            }

            //Fecha
            auxInt += values.date_.GetHashCode() + 5 * DateTime.Now.GetHashCode();
            if (auxInt >= int.MaxValue)
            {
                auxInt = auxInt % int.MaxValue;
            }

            //Local Machine
            if (values.localMachine_ != null)
            {
                for (int i = 0; i < values.localMachine_.Length; i++)
                {
                    auxInt += (values.localMachine_[i] * i);
                    if (auxInt >= int.MaxValue)
                    {
                        auxInt = auxInt % int.MaxValue;
                    }
                }
            }

            //Key Generada
            key_ = Convert.ToInt32(auxInt);
        }
    public Cryptography()
    {
        EncryptionValues = new EncryptionValues();

        LetterFrequency = new EnglishLetterFrequency();
    }