HashForKey() public static method

Takes a string of plain text and then returns a MD5 hash value
public static HashForKey ( string plainText ) : string
plainText string
return string
示例#1
0
        /// <summary>
        /// Used to Set objects in cache for a set timout lenght of time.
        /// </summary>
        /// <param name="key"></param>
        /// <param name="data"></param>


        static public void Set(string key, Object data, double cachetimeout, CacheDependency dependency)
        {
            string hashkey = string.Empty;

            hashkey = Cache.HashForKey(key);

            try
            {
                if (HttpRuntime.Cache[hashkey] != null)
                {
                    HttpRuntime.Cache.Remove(hashkey);
                }

                if (cachetimeout < 0 && dependency == null)
                {
                    HttpRuntime.Cache.Insert(hashkey, data);
                }
                else
                {
                    HttpRuntime.Cache.Insert(hashkey, data, dependency, DateTime.Now.AddSeconds(cachetimeout), System.Web.Caching.Cache.NoSlidingExpiration);
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
示例#2
0
        /// <summary>
        /// Used to Fetch RDF data or Presentation data from cache.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        static public XmlDocument Fetch(string key)
        {
            XmlDocument xmlrtn  = null;
            string      hashkey = string.Empty;

            hashkey = Cache.HashForKey(key);

            try
            {
                if (HttpRuntime.Cache[hashkey] != null)
                {
                    xmlrtn = (XmlDocument)HttpRuntime.Cache[hashkey];
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            return(xmlrtn);
        }