Encrypt() публичный статический Метод

public static Encrypt ( string PlainText ) : string
PlainText string
Результат string
Пример #1
0
 public Password(string value, bool isEncrypted)
 {
     IsEmpty   = true;
     Encrypted = null;
     if (!string.IsNullOrEmpty(value))
     {
         IsEmpty   = false;
         Encrypted = isEncrypted ? value : RijndaelSettings.Encrypt(value);
     }
 }
Пример #2
0
        private void Save(ServerDetails server_details)
        {
            #region sql
            string sql = "INSERT INTO Servers(uid, groupid, servername, server, domain, port, username, password, description, colordepth, desktopwidth, desktopheight, fullscreen) ";
            sql += "VALUES(@uid, @gid, @sname, @server, @domain, @port, @uname, @pword, @desc, @cdepth, @dwidth, @dheight, @fscreen)";
            #endregion

            #region params
            if (server_details.Password != string.Empty)
            {
                server_details.Password = RijndaelSettings.Encrypt(server_details.Password);
            }

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@uid",     server_details.UID),
                new SQLiteParameter("@gid",     server_details.GroupID),
                new SQLiteParameter("@sname",   server_details.ServerName),
                new SQLiteParameter("@server",  server_details.Server),
                new SQLiteParameter("@domain",  server_details.Domain),
                new SQLiteParameter("@port",    server_details.Port),
                new SQLiteParameter("@uname",   server_details.Username),
                new SQLiteParameter("@pword",   server_details.Password),
                new SQLiteParameter("@desc",    server_details.Description),
                new SQLiteParameter("@cdepth",  server_details.ColorDepth),
                new SQLiteParameter("@dwidth",  server_details.DesktopWidth),
                new SQLiteParameter("@dheight", server_details.DesktopHeight),
                new SQLiteParameter("@fscreen", server_details.Fullscreen)
            };
            #endregion

            string result = ExecuteNonQuery(sql, parameters);

            if (result == string.Empty)
            {
            }
            else
            {
                CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);

                if (result.Contains("Abort due to constraint violation"))
                {
                    throw new DatabaseException(DatabaseException.ExceptionTypes.DUPLICATE_ENTRY);
                }
                else
                {
                    throw new Exception(result);
                }
            }

            CloseConnection();
        }
Пример #3
0
        private void Update(Model_ServerDetails server_details)
        {
            #region sql
            string sql = @"
UPDATE 
    Servers 
SET 
    uid=@uid, 
    groupid=@gid,
    servername=@sname, 
    server=@server,
    domain=@domain,
    port=@port,
    username=@uname,
    password=@pword,
    description=@desc,
    colordepth=@cdepth, 
    desktopwidth=@dwidth,
    desktopheight=@dheight,
    fullscreen=@fscreen
WHERE
    uid=@uid";
            #endregion

            #region params
            if (server_details.Password != string.Empty)
            {
                server_details.Password = RijndaelSettings.Encrypt(server_details.Password);
            }

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@uid",     server_details.UID),
                new SQLiteParameter("@gid",     server_details.GroupID),
                new SQLiteParameter("@sname",   server_details.ServerName),
                new SQLiteParameter("@server",  server_details.Server),
                new SQLiteParameter("@domain",  server_details.Domain),
                new SQLiteParameter("@port",    server_details.Port),
                new SQLiteParameter("@uname",   server_details.Username),
                new SQLiteParameter("@pword",   server_details.Password),
                new SQLiteParameter("@desc",    server_details.Description),
                new SQLiteParameter("@cdepth",  server_details.ColorDepth),
                new SQLiteParameter("@dwidth",  server_details.DesktopWidth),
                new SQLiteParameter("@dheight", server_details.DesktopHeight),
                new SQLiteParameter("@fscreen", server_details.Fullscreen)
            };
            #endregion

            string result = base.ExecuteNonQuery(sql, parameters);

            if (result == string.Empty)
            {
            }
            else
            {
                base.Database.CloseConnection();
                System.Diagnostics.Debug.WriteLine(result);

                if (result.Contains("Abort due to constraint violation"))
                {
                    throw new DatabaseException(DatabaseException.ExceptionTypes.DUPLICATE_ENTRY);
                }
                else
                {
                    throw new Exception(result);
                }
            }

            base.Database.CloseConnection();
        }