Exemplo n.º 1
0
        public static TLString GetX(TLString password, TLPasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow algo)
        {
            var x_bytes = Telegram.Api.Helpers.Utils.ComputeSHA256(TLUtils.Combine(algo.Salt1.Data, password.Data, algo.Salt1.Data));

            x_bytes = Telegram.Api.Helpers.Utils.ComputeSHA256(TLUtils.Combine(algo.Salt2.Data, x_bytes, algo.Salt2.Data));
            x_bytes = PBKDF2.GetHash(x_bytes.AsBuffer(), algo.Salt1.Data.AsBuffer()).ToArray();
            x_bytes = Telegram.Api.Helpers.Utils.ComputeSHA256(TLUtils.Combine(algo.Salt2.Data, x_bytes, algo.Salt2.Data));

            return(TLString.FromBigEndianData(x_bytes));
        }
Exemplo n.º 2
0
        public static TLString GetNewHash(TLPasswordKdfAlgoBase kdfAlgoBase, TLString password)
        {
            var algo = kdfAlgoBase as TLPasswordKdfAlgoSHA256SHA256PBKDF2HMACSHA512iter100000SHA256ModPow;

            if (algo != null)
            {
                var salt1 = algo.Salt1;
                var salt2 = algo.Salt2;

                var hash1 = GetHash(salt1, password);
                var hash2 = GetHash(salt2, hash1);
                var hash3 = PBKDF2.GetHash(hash2.Data.AsBuffer(), salt1.Data.AsBuffer());
                var hash4 = GetHash(salt2, TLString.FromBigEndianData(hash3.ToArray()));

                return(hash4);
            }

            return(null);
        }