コード例 #1
0
        /// <summary>
        /// 加密数据
        /// </summary>
        /// <param name="item"></param>
        /// <param name="originalData"></param>
        /// <returns></returns>
        private static object EncryptPropertyValue(ORMappingItem item, object originalData)
        {
            object result = originalData;

            if (originalData != null && originalData != DBNull.Value)
            {
                if (originalData is string == false || (string)originalData != string.Empty)
                {
                    ISymmetricEncryption encryptor = ORMappingItemEncryptionHelper.GetEncryptor(item.EncryptorName);
                    result = encryptor.EncryptString(originalData.ToString()).ToBase16String();
                }
            }

            return(result);
        }
コード例 #2
0
        private static object DecryptPropertyValue(ORMappingItem item, object originalData)
        {
            object result = originalData;

            if (originalData is string)
            {
                string stringValue = (string)originalData;

                if (stringValue.IsNotEmpty())
                {
                    try
                    {
                        ISymmetricEncryption encryptor = ORMappingItemEncryptionHelper.GetEncryptor(item.EncryptorName);
                        result = encryptor.DecryptString(stringValue.ToBase16Bytes());
                    }
                    catch (System.FormatException)
                    {
                    }
                }
            }

            return(result);
        }