Esempio n. 1
0
        public static byte[] Base58ToAddress(string base58)
        {
            if (base58.IsNullOrEmpty())
            {
                Logger.Warning("Base58 string value is null.");
            }


            byte[] decode = Base58.Decode(base58);
            if (decode.Length <= 4)
            {
                return(null);
            }

            byte[] address = new byte[decode.Length - 4];
            Array.Copy(decode, 0, address, 0, address.Length);

            byte[] hash0 = SHA256Hash.ToHash(address);
            byte[] hash1 = SHA256Hash.ToHash(hash0);

            if (hash1[0] == decode[address.Length] &&
                hash1[1] == decode[address.Length + 1] &&
                hash1[2] == decode[address.Length + 2] &&
                hash1[3] == decode[address.Length + 3])
            {
                return(IsValidAddress(address) ? address : null);
            }

            return(null);
        }
Esempio n. 2
0
 private void buttonGenerateHash_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(textBoxPassword.Text))
     {
         textBoxPasswordHAsh.Text = SHA256Hash.GetHashString(textBoxPassword.Text);
     }
 }
Esempio n. 3
0
    public void btnLogin()
    {
        if ((ifLogin.text.Length >= GC.MIN_LENGTH) &&
            (ifPassword.text.Length >= GC.MIN_LENGTH))
        {
            PlayerData.Saved.name = ifLogin.text;

            if (tglRemember.isOn)
            {
                if (ifPassword.text != GC.PASS_DUMMY)
                {
                    string hash = SHA256Hash.HashString(ifPassword.text);
                    if (PlayerData.Saved.passwordHash != hash)
                    {
                        PlayerData.Saved.passwordHash = hash;
                    }
                }
            }

            PlayerData.Saved.remember = tglRemember.isOn;

            PlayerData.Save();

            LoginIO.SendAuthorization(
                ifLogin.text,
                ifPassword.text);
        }
        else
        {
            //TODO visualize the reason of the issue
            Debug.LogError("Login and/or password to short! Please check if it is OK.");
        }
    }
Esempio n. 4
0
 public BlockId(SHA256Hash block_id)
     : base(block_id.Hash)
 {
     byte[] block_num = new byte[8];
     Array.Copy(block_id.Hash, 0, block_num, 0, 8);
     this.num = BitConverter.ToInt64(block_num, 0);
 }
            public override KeyValuePair <bool, byte[]> Execute(byte[] data)
            {
                if (data == null)
                {
                    return(new KeyValuePair <bool, byte[]>(true, SHA256Hash.ToHash(new byte[0])));
                }

                return(new KeyValuePair <bool, byte[]>(true, SHA256Hash.ToHash(data)));
            }
        public string GetEndLinkHash(int userId, int quizId)
        {
            string lineForHash   = $"{userId}#{quizId}#QuiZoneSecurityHash";
            string startHashPass = $"{SHA256Hash.ComputeString(lineForHash)}#QuiZoneSecurityHash";
            string reverseHash   = new string(startHashPass.ToCharArray().Reverse().ToArray());
            string finalHashPass = SHA256Hash.ComputeString(reverseHash);

            return(finalHashPass);
        }
Esempio n. 7
0
        public void RemoveBlock(SHA256Hash hash)
        {
            if (!this.mini_store.Remove(hash))
            {
                this.mini_unlinked_store.Remove(hash);
            }

            SetHead(this.mini_store.GetFirst());
        }
Esempio n. 8
0
        public static string Encode58Check(byte[] input)
        {
            byte[] hash0 = SHA256Hash.ToHash(input);
            byte[] hash1 = SHA256Hash.ToHash(hash0);
            byte[] check = new byte[input.Length + 4];

            Array.Copy(input, 0, check, 0, input.Length);
            Array.Copy(hash1, 0, check, input.Length, 4);

            return(Base58.Encode(check));
        }
        public virtual ActionResult Index(PasswordHashGeneratorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("_PasswordHashForm", model));
            }

            model.Salt         = SHA256Hash.CreateSalt(6);
            model.PasswordHash = SHA256Hash.HashValue(model.Password, model.Salt);
            return(View("_PasswordHashForm", model));
        }
 public override KeyValuePair <bool, byte[]> Execute(byte[] data)
 {
     byte[] target = new byte[20];
     if (data == null)
     {
         data = new byte[0];
     }
     byte[] orig = SHA256Hash.ToHash(data);
     Array.Copy(orig, 0, target, 0, 20);
     return(new KeyValuePair <bool, byte[]>(true, SHA256Hash.ToHash(target)));
 }
Esempio n. 11
0
        public BlockCapsule GetBlockById(SHA256Hash hash)
        {
            BlockCapsule block = this.khaos_database.GetBlock(hash);

            if (block == null)
            {
                block = this.block_store.Get(hash.Hash);
            }

            return(block);
        }
Esempio n. 12
0
        public void When_file_is_hashed_no_error_is_thrown_and_correct_hash_is_returned()
        {
            //Arrange
            var expectedString = "3EC32196F7277C895B6C8E9FF51FF9FF820F0399EC6804524780B142507C8D7B";

            //Act
            var result = SHA256Hash.GetHashFromFile("TestFiles/file.exe");

            //Assert
            result.Should().Be(expectedString);
        }
Esempio n. 13
0
        public async Task CheckHashFailTest()
        {
            // Arrange
            var handler = new SHA256Hash();

            // Act
            bool matches = await handler.CheckHashAsync(sample, failHash);

            // Assert
            Assert.IsFalse(matches);
        }