예제 #1
0
        /// <summary>
        /// 得到加密后的值
        /// </summary>
        /// <returns></returns>
        public static string ToEncryptorValue(this object originalData)
        {
            ISymmetricEncryption encryptor = new ORMappintItemEncryption("DefaultPropertyEncryptor");
            var result = encryptor.EncryptString(originalData.ToString()).ToBase16String();

            return(result);
        }
		/// <summary>
		/// 得到加密器
		/// </summary>
		/// <param name="name"></param>
		/// <returns></returns>
		public static ISymmetricEncryption GetEncryptor(string name)
		{
			ISymmetricEncryption result = null;

			using (ORMappingContext context = ORMappingContext.GetContext())
			{
				if (name.IsNullOrEmpty())
					name = "DefaultPropertyEncryptor";

				result = context.ItemEncryptors[name];

				if (result == null)
				{
					result = new ORMappintItemEncryption(name);
					context.ItemEncryptors.Add((ORMappintItemEncryption)result);
				}
			}

			return result;
		}