コード例 #1
0
        protected internal virtual string Serialize(LegacyCredential cred)
        {
            string encodedSalt     = HexString.encodeHexString(cred.Salt());
            string encodedPassword = HexString.encodeHexString(cred.PasswordHash());

            return(string.join(CREDENTIAL_SEPARATOR, LegacyCredential.DIGEST_ALGO, encodedPassword, encodedSalt));
        }
コード例 #2
0
        public virtual string AsHex()
        {
            // Convert the flags to a byte-array, each
            // flag represented as a single bit.
            sbyte[] bits = new sbyte[_flags.Length / 8];

            // Go over the flags, eight at a time to align
            // with sticking eight bits at a time into the
            // output array.
            for (int i = 0; i < _flags.Length; i += 8)
            {
                bits[i / 8] = ( sbyte )((Bit(i) << 7) | (Bit(i + 1) << 6) | (Bit(i + 2) << 5) | (Bit(i + 3) << 4) | (Bit(i + 4) << 3) | (Bit(i + 5) << 2) | (Bit(i + 6) << 1) | (Bit(i + 7)));
            }
            return(HexString.encodeHexString(bits));
        }