Example #1
0
        /// <summary>
        /// Encrypts the specified to encrypt.
        /// </summary>
        /// <param name="toEncrypt">To encrypt.</param>
        /// <returns></returns>
        public static string Encrypt(string toEncrypt)
        {
            if (string.IsNullOrEmpty(toEncrypt))
            {
                Logger.Warn("Unable to encrypt null or empty string instance");
                return(null);
            }

            return(SimpleEncryption.Encrypt(toEncrypt, PassPhrase));
        }
Example #2
0
        /// <summary>
        /// Encrypts the specified instance.
        /// </summary>
        /// <param name="instance">Object instance submitted for encryption.</param>
        /// <returns>The value byte[] will be returned if encryption was successful;
        /// null for otherwise.</returns>
        public static byte[] Encrypt(object instance)
        {
            if (instance == null)
            {
                Logger.Warn("Unable to encrypt NULL instance");
                return(null);
            }

            if (Logger.IsDebugEnabled)
            {
                Logger.DebugFormat("Encrypting instance: {0}", instance);
            }

            byte[] serializedInstance = ObjectUtil.ConvertToByteArray(instance);

            if (serializedInstance == null)
            {
                return(null);
            }

            return(SimpleEncryption.Encrypt(serializedInstance, PassPhrase));
        }