GenerateHash() public static method

public static GenerateHash ( String pwd ) : String
pwd String
return String
Exemplo n.º 1
0
        /**
         * @param level Document protecton level
         * @param pwd Document password - clear text
         * @since 2.1.1
         * @author Howard Shank ([email protected])
         */
        public bool SetProtection(int level, String pwd)
        {
            bool result = false;

            if (this.protectionHash == null)
            {
                if (!SetProtectionLevel(level))
                {
                    result = false;
                }
                else
                {
                    protectionHash = RtfProtection.GenerateHash(pwd);
                    result         = true;
                }
            }
            else
            {
                if (this.protectionHash.Equals(RtfProtection.GenerateHash(pwd)))
                {
                    if (!SetProtectionLevel(level))
                    {
                        result = false;
                    }
                    else
                    {
                        protectionHash = RtfProtection.GenerateHash(pwd);
                        result         = true;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        /**
         * @param oldPwd Old password - clear text
         * @param newPwd New password - clear text
         * @return true if password set, false if password not set
         * @since 2.1.1
         * @author Howard Shank ([email protected])
         */
        public bool SetNewPassword(String oldPwd, String newPwd)
        {
            bool result = false;

            if (this.protectionHash.Equals(RtfProtection.GenerateHash(oldPwd)))
            {
                this.protectionHash = RtfProtection.GenerateHash(newPwd);
                result = true;
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// @since 2.1.1
        /// @author Howard Shank ([email protected])
        /// </summary>
        /// <param name="oldPwd">Old password - clear text</param>
        /// <param name="newPwd">New password - clear text</param>
        /// <returns>true if password set, false if password not set</returns>
        public bool SetNewPassword(string oldPwd, string newPwd)
        {
            var result = false;

            if (_protectionHash.Equals(RtfProtection.GenerateHash(oldPwd)))
            {
                _protectionHash = RtfProtection.GenerateHash(newPwd);
                result          = true;
            }
            return(result);
        }
Exemplo n.º 4
0
        /**
         * @param pwd Document password - clear text
         * @return true if document unprotected, false if protection is not removed.
         * @since 2.1.1
         * @author Howard Shank ([email protected])
         */
        public bool UnprotectDocument(String pwd)
        {
            bool result = false;

            if (this.protectionHash.Equals(RtfProtection.GenerateHash(pwd)))
            {
                this.protectionLevel = RtfProtection.LEVEL_NONE;
                this.protectionHash  = null;
                result = true;
            }
            return(result);
        }
Exemplo n.º 5
0
        /// <summary>
        /// @since 2.1.1
        /// @author Howard Shank ([email protected])
        /// </summary>
        /// <param name="pwd">Document password - clear text</param>
        /// <returns>true if document unprotected, false if protection is not removed.</returns>
        public bool UnprotectDocument(string pwd)
        {
            var result = false;

            if (_protectionHash.Equals(RtfProtection.GenerateHash(pwd)))
            {
                _protectionLevel = RtfProtection.LEVEL_NONE;
                _protectionHash  = null;
                result           = true;
            }
            return(result);
        }