예제 #1
0
        internal static NetworkCredential Get(NetworkCredentialXML value)
        {
            if (value == null)
            {
                return(null);
            }
            string password;

            if (value.EncryptedPassword != null)
            {
                byte[] bytes = CryptoTools.Decrypt(value.EncryptedPassword, NetworkCredentialXML.PwdEncryptionKey);
                password = Encoding.Unicode.GetString(bytes);
            }
            else
            {
                password = null;
            }
            return(new NetworkCredential(value.Username, password, value.Domain));
        }
예제 #2
0
        internal static NetworkCredentialXML Get(NetworkCredential nc)
        {
            if (nc == null)
            {
                return(null);
            }
            NetworkCredentialXML networkCredentialXML = new NetworkCredentialXML();

            networkCredentialXML.Username = nc.UserName;
            networkCredentialXML.Domain   = nc.Domain;
            if (string.IsNullOrEmpty(nc.Password))
            {
                networkCredentialXML.EncryptedPassword = null;
            }
            else
            {
                networkCredentialXML.EncryptedPassword = CryptoTools.Encrypt(Encoding.Unicode.GetBytes(nc.Password), NetworkCredentialXML.PwdEncryptionKey);
            }
            return(networkCredentialXML);
        }