Ejemplo n.º 1
0
        /// <summary>
        ///     Decrypt the result received and retrieve it.
        /// </summary>
        /// <param name="idAlgo"></param>
        /// <param name="result"></param>
        /// <param name="size"></param>
        /// <param name="AesIv"></param>
        /// <param name="AesSalt"></param>
        /// <returns></returns>
        public static string GetDecryptedResult(string idAlgo, string result, int size, byte[] AesIv, byte[] AesSalt)
        {
            if (result == ClassSeedNodeStatus.SeedNone || result == ClassSeedNodeStatus.SeedError)
            {
                return(result);
            }

            try
            {
                switch (idAlgo)
                {
                case ClassAlgoEnumeration.Rijndael:
                    if (ClassUtils.IsBase64String(result))
                    {
                        return(Rijndael.DecryptString(result, size, AesIv, AesSalt));
                    }

                    break;

                case ClassAlgoEnumeration.Xor:
                    break;
                }
            }
            catch (Exception erreur)
            {
                return(ClassAlgoErrorEnumeration.AlgoError);
            }

            return(ClassAlgoErrorEnumeration.AlgoError);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Decrypt the result received and retrieve it.
        /// </summary>
        /// <param name="idAlgo"></param>
        /// <param name="result"></param>
        /// <param name="key"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static string GetDecryptedResult(string idAlgo, string result, int size, byte[] AesIv, byte[] AesSalt)
        {
            if (result == ClassSeedNodeStatus.SeedNone)
            {
                return(result);
            }

            try
            {
                switch (idAlgo)
                {
                case ClassAlgoEnumeration.Rijndael:
                    using (var decrypt = new Rijndael())
                    {
                        return(decrypt.DecryptString(result, size, AesIv, AesSalt));
                    }

                case ClassAlgoEnumeration.Xor:
                    break;
                }
            }
            catch (Exception erreur)
            {
                return(ClassAlgoErrorEnumeration.AlgoError);
            }

            return(ClassAlgoErrorEnumeration.AlgoError);
        }