예제 #1
0
        //inserts all
        public void OneInsertEach()
        {
            HashingEntitiesConn context = new HashingEntitiesConn();

            context.Database.Log += Console.WriteLine;
            try
            {
                context.Configuration.AutoDetectChangesEnabled = false;

                foreach (string password in arrangements)
                {
                    Console.WriteLine(password);

                    string md5hash  = HashesClass.computeHash(password, "MD5");
                    string sha1hash = HashesClass.computeHash(password, "SHA1");
                    string sha2hash = HashesClass.computeHash(password, "SHA256");

                    var rainbow = new Rainbow()
                    {
                        password = password,
                        md5hash  = md5hash,
                        sha1hash = sha1hash,
                        sha2hash = sha2hash
                    };
                    context.Rainbows.Add(rainbow);
                    //context.SaveChanges();
                }

                context.SaveChanges();
            }
            finally
            {
                context.Configuration.AutoDetectChangesEnabled = true;
            }
        }
예제 #2
0
        public void AddRange()
        {
            HashingEntitiesConn context = null;

            try
            {
                context = new HashingEntitiesConn();
                context.Database.Log += Console.WriteLine;
                context.Configuration.AutoDetectChangesEnabled = false;
                List <Rainbow> rainbows = new List <Rainbow>();

                foreach (string password in arrangements)
                {
                    string md5hash  = HashesClass.computeHash(password, "MD5");
                    string sha1hash = HashesClass.computeHash(password, "SHA1");
                    string sha2hash = HashesClass.computeHash(password, "SHA256");

                    rainbows.Add(new Rainbow()
                    {
                        password = password,
                        md5hash  = md5hash,
                        sha1hash = sha1hash,
                        sha2hash = sha2hash
                    });
                }

                Console.WriteLine("finished loading");

                context.Rainbows.AddRange(rainbows);
                context.SaveChanges();
            }
            finally
            {
                if (context != null)
                {
                    context.Dispose();
                }
            }
        }