Exemple #1
0
        internal virtual void GeneratePWD(string pwd)
        {
            int          i;
            IList <byte> temp = new List <byte>();

            byte[] tmp;
            tmp = System.Text.Encoding.Default.GetBytes(pwd);
            hasher.Reset();
            hasher.Update(tmp);
            foreach (byte b in tmp)
            {
                temp.Add(b);
            }
            tmp = BitConverter.GetBytes(hasher.Value);
            foreach (byte b in tmp)
            {
                temp.Add(b);
            }
            for (i = 0; i < 128; i++)
            {
                if (i < temp.Count)
                {
                    m_key[i] = (byte)(temp[i] ^ WhisperTable[temp[i % temp.Count] % 64]);
                }
                else
                {
                    m_key[i] = (byte)((m_key[(i + 1) % temp.Count] & 0xc0 | m_key[(i + 3) % temp.Count] & 0x30 | m_key[i % temp.Count] & 0x0c | m_key[(i + 2) % temp.Count] & 0x03) ^ WhisperTable[temp[i % temp.Count] % 64]);
                }
            }
            hasher.Reset();
            hasher.Update(m_key);
            m_seed = (int)hasher.Value;
            KBox.initkbox(m_seed);
        }