예제 #1
0
        /// <summary>
        /// Pack database with option 'save file permission'
        /// </summary>
        /// <param name="oldPassword">Old password</param>
        /// <param name="oldCypher">Old cypher</param>
        /// <param name="newPassword">New password</param>
        /// <param name="newCypher">New cypher</param>
        /// <param name="newCaseSensitive">New case sensitive option</param>
        /// <param name="newLocale">New locale</param>
        /// <param name="MarkFullEncryption">Mark full encryption option</param>
        /// <param name="SaveFilePermission">Save file permission option</param>
        /// <returns>True for success</returns>
        public bool PackDatabase(string oldPassword, CypherType oldCypher,
                                 string newPassword, CypherType newCypher, bool newCaseSensitive,
                                 int newLocale, bool MarkFullEncryption, bool SaveFilePermission)
        {
            bool needOpen, res;

            lock (SyncRoot)
            {
                if (databaseId > 0)
                {
                    needOpen = true;
                    CloseWithoutSync();
                }
                else
                {
                    needOpen = false;
                }

                res = VistaDBAPI.ivdb_PackDatabase(databaseName, oldPassword, (uint)oldCypher,
                                                   newPassword, (uint)newCypher, newCaseSensitive, newLocale, MarkFullEncryption,
                                                   SaveFilePermission);

                password = newPassword;
                cypher   = newCypher;

                if (needOpen)
                {
                    ConnectWithoutSync();
                }

                return(res);
            }
        }
예제 #2
0
 /// <summary>
 /// Pack database
 /// <param name="oldPassword">Old password</param>
 /// <param name="oldCypher">Old cypher</param>
 /// <param name="newPassword">New password</param>
 /// <param name="newCypher">New cypher</param>
 /// <param name="newCaseSensitive">New case sensitive option</param>
 /// <param name="newLocale">New locale</param>
 /// <param name="MarkFullEncryption">Mark full encryption option</param>
 /// </summary>
 /// <returns>True for success</returns>
 public bool PackDatabase(string oldPassword, CypherType oldCypher,
                          string newPassword, CypherType newCypher, bool newCaseSensitive,
                          int newLocale, bool MarkFullEncryption)
 {
     return(PackDatabase(oldPassword, oldCypher, newPassword, newCypher, newCaseSensitive,
                         newLocale, MarkFullEncryption, false));
 }
예제 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public VistaDBSQL()
        {
            dataSource = "";
            dataBase   = "";
            cypher     = CypherType.None;
            password   = "";
            exclusive  = false;
            readOnly   = false;
            opened     = false;
            queries    = new VistaDBSQLQuery[0];

            connectionID = VistaDBAPI.ivsql_CreateDatabaseConnection();
        }
		/// <summary>
		/// Constructor.
		/// </summary>
		public VistaDBSQLConnection()
		{
			this.dataSource          = "";
			this.database            = "";
			this.cypher              = CypherType.None;
			this.password            = "";
			this.exclusive           = false;
			this.readOnly            = false;
			this.opened              = false;
			this.queries             = new VistaDBSQLQuery[0];
			this.cultureID           = 0;
			this.clusterSize         = 0;
			this.caseSensitivity     = false;
			this.databaseDescription = "";
		}
 /// <summary>
 /// Constructor.
 /// </summary>
 public VistaDBSQLConnection()
 {
     this.dataSource          = "";
     this.database            = "";
     this.cypher              = CypherType.None;
     this.password            = "";
     this.exclusive           = false;
     this.readOnly            = false;
     this.opened              = false;
     this.queries             = new VistaDBSQLQuery[0];
     this.cultureID           = 0;
     this.clusterSize         = 0;
     this.caseSensitivity     = false;
     this.databaseDescription = "";
 }
예제 #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public VistaDBConnection()
        {
            VistaDBErrorMsgs.SetErrorFunc();
            this.connectionState = ConnectionState.Closed;
            this.accessMode      = AccessMode.Local;
            this.vistaDBSQL      = null;

            this.dataSource    = null;
            this.database      = null;
            this.cypher        = CypherType.None;
            this.password      = null;
            this.exclusive     = false;
            this.readOnly      = false;
            this.loginUser     = "";
            this.loginPassword = "";
        }
예제 #7
0
		/// <summary>
		/// Constructor.
		/// </summary>
		public VistaDBConnection()
		{
			VistaDBErrorMsgs.SetErrorFunc();
			this.connectionState = ConnectionState.Closed;
			this.accessMode      = AccessMode.Local;
			this.vistaDBSQL      = null;

			this.dataSource      = null;
			this.database        = null;
			this.cypher          = CypherType.None;
			this.password        = null;
			this.exclusive       = false;
			this.readOnly        = false;
			this.loginUser       = "";
			this.loginPassword   = "";
		}
예제 #8
0
		public static bool ivsql_OpenDatabaseConnection(
			int connectionID, 
			string cpDataBaseName, 
			bool Exclusive, 
			bool ReadOnly, 
			CypherType defaultCypher, 
			string defaultPassword,
			bool CaseSensitive
			)
		{
			bool res = vsql_OpenDatabaseConnection(connectionID, cpDataBaseName, Exclusive, ReadOnly, defaultCypher, defaultPassword, CaseSensitive);
			VistaDBErrorMsgs.ShowErrors(!res, res);

			return res;
		}
예제 #9
0
		private static extern bool vsql_OpenDatabaseConnection(
			int connectionID, 
			[MarshalAs(UnmanagedType.LPStr)] string cpDataBaseName, 
			bool Exclusive, 
			bool ReadOnly, 
			CypherType defaultCypher, 
			[MarshalAs(UnmanagedType.LPStr)] string defaultPassword,
			bool CaseSensitive
			);
		/// <summary>
		/// Constructor.
		/// </summary>
		public VistaDBSQL()
		{
			dataSource = "";
			dataBase = "";
			cypher = CypherType.None;
			password = "";
			exclusive = false;
			readOnly = false;
			opened = false;
			queries = new VistaDBSQLQuery[0];

			connectionID = VistaDBAPI.ivsql_CreateDatabaseConnection();
		}
예제 #11
0
        //Usar Enum para o cypherType
        //Lançar exception caso o cypherType não seja conhecido.
        public string GetHash(string value, string saltValue, CypherType cypher)
        {
            saltValue = (saltValue == null) ? string.Empty : saltValue;
            StringBuilder strSenhaHash = new StringBuilder();

            byte[] arrSenhaHash = null;
            switch (cypher)
            {
            case CypherType.SHA512:
                SHA512 alg = SHA512.Create();

                if (saltValue.Length > 0)
                {
                    value = string.Concat(saltValue.Substring(0, 18), value, saltValue.Substring(18));
                }

                byte[] result = alg.ComputeHash(Encoding.ASCII.GetBytes(value));
                arrSenhaHash = alg.ComputeHash(result);

                foreach (byte b in result)
                {
                    strSenhaHash.Append(b.ToString("X2"));
                }
                return(strSenhaHash.ToString());

            case CypherType.SHA1:
                HashAlgorithm AlgoritimoHash = new SHA1Managed();

                byte[] arrSenhaBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(value);
                arrSenhaHash = AlgoritimoHash.ComputeHash(arrSenhaBytes);

                foreach (byte b in arrSenhaHash)
                {
                    strSenhaHash.Append(b.ToString("X2"));
                }

                return(strSenhaHash.ToString());

            case CypherType.MD5:

                string strSenhaMD5 = FormsAuthentication.HashPasswordForStoringInConfigFile(value, "md5");
                return(strSenhaMD5.ToLower());

            default:
                SHA512 algoSha = SHA512.Create();

                if (saltValue.Length > 0)
                {
                    value = string.Concat(saltValue.Substring(0, 18), value, saltValue.Substring(18));
                }

                byte[] resultSha = algoSha.ComputeHash(Encoding.ASCII.GetBytes(value));
                arrSenhaHash = algoSha.ComputeHash(resultSha);

                foreach (byte b in resultSha)
                {
                    strSenhaHash.Append(b.ToString("X2"));
                }
                return(strSenhaHash.ToString());
            }
        }
예제 #12
0
 /// <summary>
 /// Pack database
 /// <param name="newPassword">New password</param>
 /// <param name="newCypher">New cypher</param>
 /// <param name="MarkFullEncryption">Mark full encryption option</param>
 /// </summary>
 /// <returns>True for success</returns>
 public bool PackDatabase(string newPassword, CypherType newCypher, bool MarkFullEncryption)
 {
     return(PackDatabase(password, cypher, newPassword, newCypher,
                         CaseSensitive, Locale, MarkFullEncryption));
 }
예제 #13
0
		/// <summary>
		/// Pack database with option 'save file permission'
		/// </summary>
		/// <param name="oldPassword">Old password</param>
		/// <param name="oldCypher">Old cypher</param>
		/// <param name="newPassword">New password</param>
		/// <param name="newCypher">New cypher</param>
		/// <param name="newCaseSensitive">New case sensitive option</param>
		/// <param name="newLocale">New locale</param>
		/// <param name="MarkFullEncryption">Mark full encryption option</param>
		/// <param name="SaveFilePermission">Save file permission option</param>
		/// <returns>True for success</returns>
		public bool PackDatabase(string oldPassword, CypherType oldCypher, 
			string newPassword, CypherType newCypher, bool newCaseSensitive,
			int newLocale, bool MarkFullEncryption, bool SaveFilePermission)
		{
			bool needOpen, res;

			lock(SyncRoot)
			{
				if(databaseId > 0)
				{
					needOpen = true;
					CloseWithoutSync();
				}
				else
					needOpen = false;

				res = VistaDBAPI.ivdb_PackDatabase(databaseName, oldPassword, (uint)oldCypher,
					newPassword, (uint)newCypher, newCaseSensitive, newLocale, MarkFullEncryption,
					SaveFilePermission);

				password = newPassword;
				cypher = newCypher;

				if( needOpen )
					ConnectWithoutSync();

				return res;
			}
		}
예제 #14
0
		/// <summary>
		/// Pack database
		/// <param name="oldPassword">Old password</param>
		/// <param name="oldCypher">Old cypher</param>
		/// <param name="newPassword">New password</param>
		/// <param name="newCypher">New cypher</param>
		/// <param name="newCaseSensitive">New case sensitive option</param>
		/// <param name="newLocale">New locale</param>
		/// <param name="MarkFullEncryption">Mark full encryption option</param>
		/// </summary>
		/// <returns>True for success</returns>
		public bool PackDatabase(string oldPassword, CypherType oldCypher, 
			string newPassword, CypherType newCypher, bool newCaseSensitive,
			int newLocale, bool MarkFullEncryption)
		{
			return PackDatabase(oldPassword, oldCypher, newPassword, newCypher, newCaseSensitive,
				newLocale, MarkFullEncryption, false);
		}
예제 #15
0
		/// <summary>
		/// Pack database
		/// <param name="newPassword">New password</param>
		/// <param name="newCypher">New cypher</param>
		/// <param name="newCaseSensitive">New case sensitive option</param>
		/// <param name="newLocale">New locale</param>
		/// <param name="MarkFullEncryption">Mark full encryption option</param>
		/// </summary>
		/// <returns>True for success</returns>
		public bool PackDatabase(string newPassword, CypherType newCypher, 
			bool newCaseSensitive, int newLocale, bool MarkFullEncryption)
		{
			return PackDatabase(password, cypher, newPassword, newCypher, 
				newCaseSensitive, newLocale, MarkFullEncryption);
		}