예제 #1
0
            internal void WriteHashAndKey(BinaryWriterEx bw, Game game, int bucketIndex, int fileIndex)
            {
                if (game >= Game.DarkSouls2)
                {
                    if (SHAHash == null)
                    {
                        bw.FillInt64($"SHAHashOffset{bucketIndex}:{fileIndex}", 0);
                    }
                    else
                    {
                        bw.FillInt64($"SHAHashOffset{bucketIndex}:{fileIndex}", bw.Position);
                        SHAHash.Write(bw);
                    }

                    if (AESKey == null)
                    {
                        bw.FillInt64($"AESKeyOffset{bucketIndex}:{fileIndex}", 0);
                    }
                    else
                    {
                        bw.FillInt64($"AESKeyOffset{bucketIndex}:{fileIndex}", bw.Position);
                        AESKey.Write(bw);
                    }
                }
            }
예제 #2
0
        public void ComputeHash_WithoutSalt_ComputesSameHash()
        {
            // Arrange
            var secret = "my super secret password";

            // Act
            var result1 = SHAHash.ComputeHash(secret);
            var result2 = SHAHash.ComputeHash(secret);

            // Assert
            Assert.Equal(result1.HashedData, result2.HashedData);
            Assert.Equal(result1.Salt, result2.Salt);
        }
예제 #3
0
        public void ComputeHash_WithoutSalt_ComputesDifferentHashForDifferentValues()
        {
            // Arrange
            var secret1 = "my super secret password";
            var secret2 = "my super secret password, part deux";

            // Act
            var result1 = SHAHash.ComputeHash(secret1);
            var result2 = SHAHash.ComputeHash(secret2);

            // Assert
            Assert.NotEqual(result1.HashedData, result2.HashedData);
            Assert.Equal(result1.Salt, result2.Salt);
        }
예제 #4
0
 public bool Equals(FileItem other)
 {
     if (Object.ReferenceEquals(other, null))
     {
         return(false);
     }
     if (object.ReferenceEquals(this, other))
     {
         return(true);
     }
     return(FileName.Equals(other.FileName) &&
            RootPath.Equals(other.RootPath) &&
            SHAHash.Equals(other.SHAHash) &&
            FileSize.Equals(other.FileSize));
 }
예제 #5
0
        public void ComputeHash_WithDifferentSalt_ComputesDifferentHash()
        {
            // Arrange
            var secret = "my super secret password";
            var salt1  = SHAHash.GenerateSalt(128);
            var salt2  = SHAHash.GenerateSalt(128);

            // Act
            var result1 = SHAHash.ComputeHash(secret, salt1);
            var result2 = SHAHash.ComputeHash(secret, salt2);

            // Assert
            Assert.NotEqual(result1.HashedData, result2.HashedData);
            Assert.Equal(salt1, result1.Salt);
            Assert.Equal(salt2, result2.Salt);
        }
예제 #6
0
        public bool CreateAccount([FromBody] LoginModel login)
        {
            DBConnectionHelper dbHelp = new DBConnectionHelper("digitaloceanmvc");


            Tuple <string, string> loginInfo = SHAHash.HashPassword(login.username, login.password);

            Console.WriteLine(loginInfo.Item1 + loginInfo.Item2);// Item 1 Contains the password * item2 contains the salt

            //store username, password, email, salt in db
            dbHelp.IsConnect();
            try
            {
                dbHelp.InsertUser(login.username, loginInfo.Item1, login.email, loginInfo.Item2);
            }catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            dbHelp.Connection.Close();

            return(true);
        }
예제 #7
0
파일: BHD5.cs 프로젝트: AinTunez/MegaTAE
            internal FileHeader(BinaryReaderEx br, Game game)
            {
                FileNameHash   = br.ReadUInt32();
                PaddedFileSize = br.ReadInt32();
                FileOffset     = br.ReadInt64();

                SHAHash = null;
                AESKey  = null;
                if (game == Game.DarkSouls2 || game == Game.DarkSouls3 || game == Game.Sekiro)
                {
                    long shaHashOffset = br.ReadInt64();
                    long aesKeyOffset  = br.ReadInt64();

                    if (shaHashOffset != 0)
                    {
                        br.StepIn(shaHashOffset);
                        {
                            SHAHash = new SHAHash(br);
                        }
                        br.StepOut();
                    }

                    if (aesKeyOffset != 0)
                    {
                        br.StepIn(aesKeyOffset);
                        {
                            AESKey = new AESKey(br);
                        }
                        br.StepOut();
                    }
                }

                UnpaddedFileSize = -1;
                if (game == Game.DarkSouls3 || game == Game.Sekiro)
                {
                    UnpaddedFileSize = br.ReadInt64();
                }
            }