Exemple #1
0
        public static void Seed(CinemaContext context)
        {
            var hasher = new StringHasher();

            for (int i = 1; i <= 10; i++)
            {
                context.Users.Add(new User
                {
                    Id    = Guid.NewGuid(),
                    Name  = "User" + i,
                    Email = i + "@movie.com",
                    ContactByEmailAllowed = true,
                    MobilePhone           = "" + i + i + i + i + i,
                    ContactBySmslAllowed  = true,
                    Password     = hasher.GetHash("123", "user" + i),
                    PasswordSalt = "user" + i,
                    Role         = "User",
                    UserType     = (UserType)(i % 3)
                });
            }

            for (int i = 1; i <= 5; i++)
            {
                context.Users.Add(new User
                {
                    Id    = Guid.NewGuid(),
                    Name  = "Editor" + i,
                    Email = "editor" + i + "@movie.com",
                    ContactByEmailAllowed = true,
                    MobilePhone           = "" + i + i + i + i + i,
                    ContactBySmslAllowed  = true,
                    Password     = hasher.GetHash("123", "editor" + i),
                    PasswordSalt = "editor" + i,
                    Role         = "Editor",
                    UserType     = (UserType)(i % 3)
                });
            }

            context.SaveChanges();
        }
Exemple #2
0
        private static string CalculateHashString(ObscureKind obscureKind, string guidIdentity)
        {
            StringHasher stringHasher = new StringHasher();

            return(stringHasher.GetHash(guidIdentity + obscureKind).ToString(NumberFormatInfo.InvariantInfo));
        }
Exemple #3
0
        static void RunSuperHasher9000TM()
        {
            Console.Clear();
            Utils.Bastard.Say("<<< SUPER HASHER 9000(tm) >>>");

            var readLine = new Func <string>(() => {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.Write("> ");

                Console.ResetColor();

                return(Console.ReadLine());
            });

            var respond = new Action <string>((s) => {
                Utils.Bastard.Say($"{s}");
            });

            var line = "";

            while ((line = readLine()) != null)
            {
                if (line.Length == 0)
                {
                    respond("Type something, dumbass!");
                    continue;
                }

                switch (line[0])
                {
                case '?':
                {
                    var sb  = new StringBuilder();
                    var num = 0;

                    foreach (var hash in StringHasher.GetMissingHashes().OrderBy((k) => $"{k:X8}"))
                    {
                        if ((num % 10) == 0.0)
                        {
                            if (num > 0)
                            {
                                sb.AppendLine();
                            }

                            sb.Append($" - ");
                        }

                        sb.Append($"{hash:X8} ");
                        num++;
                    }

                    sb.AppendLine();

                    if (num > 0)
                    {
                        respond($"{num} unknown hashes:");
                        respond(sb.ToString());
                    }
                    else
                    {
                        respond("You should probably load something first, dumbass.");
                    }
                } continue;

                case '@':
                {
                    var file = line.Substring(1).Replace("\"", "");

                    try
                    {
                        respond("Loading...");

                        var resource = ResourceFactory.Open(file);

                        if (resource != null)
                        {
                            respond("Done.");
                        }
                        else
                        {
                            respond("Fail.");
                        }
                    }
                    catch (Exception)
                    {
                        respond("Nope.");
                    }
                } continue;

                default:
                {
                    var hash = 0;

                    if (line[0] == '$')
                    {
                        try
                        {
                            hash = int.Parse(line.Substring(1), NumberStyles.HexNumber);
                        }
                        catch (Exception)
                        {
                            respond("You're an idiot.");
                            continue;
                        }
                    }
                    else
                    {
                        switch (line)
                        {
                        case "help":
                            respond("I'm afraid I can't do that, Dave.");
                            continue;

                        case "exit":
                            respond("You can check out anytime you like, but you can never leave.");
                            continue;
                        }

                        hash = StringHasher.GetHash(line);
                    }

                    if (StringHasher.CanResolveHash(hash))
                    {
                        respond($"{hash:X8} : '{line}'");
                    }
                    else
                    {
                        if (StringHasher.IsMissingHash(hash))
                        {
                            Console.ForegroundColor = ConsoleColor.DarkGreen;
                            Console.WriteLine("You found a missing hash!");

                            Console.ResetColor();
                        }

                        respond($"{hash:X8} : (unknown)");
                    }
                } continue;
                }
            }
        }