示例#1
0
        /// <summary>
        /// Cripta il testo fornito
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="clearText"></param>
        /// <returns></returns>
        internal string Encrypt(BusinessSlot slot, Property prop, string clearText)
        {
            var sEnc = string.Concat(S_ENC_PREFIX, RSA_AES_Encryptor.AES_Encrypt_B64_Text(clearText, slot.PropertyGet(this.mSlotKeyProperty).ToString(), Encoding.UTF8));

            if (sEnc.Length > this.mFieldLen)
            {
                throw new ObjectException(Resources.ObjectMessages.Prop_Enc_Wrong_Length, prop.Name, this.mFieldLen);
            }

            return(sEnc);
        }
示例#2
0
        /// <summary>
        /// Decripta il testo fornito
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="encText"></param>
        /// <returns></returns>
        internal string Decrypt(BusinessSlot slot, Property prop, string encText)
        {
            if (!this.IsEncrypted(encText))
            {
                return(encText);
            }

            try
            {
                return(RSA_AES_Encryptor.AES_Decrypt_B64_Text(encText.Substring(S_ENC_PREFIX.Length), slot.PropertyGet(this.mSlotKeyProperty).ToString(), Encoding.UTF8));
            }
            catch (Exception ex)
            {
                throw new ObjectException(Resources.ObjectMessages.Enc_Decrypt_Failure, prop.Schema.ClassName, prop.Name, ex.Message);
            }
        }