Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi Team

I have this issue and have dll files under bin folder as well reference do correspond to my project to see them. How do i fix this issue?

What I have tried:

C#
//IdentityConfig.cs
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using eNtsaTrainingRegistration.Models;
using System.Net.Mail;
using System.Net;
using System.Web.Configuration;

namespace eNtsaTrainingRegistration
{
    public class EmailService : IIdentityMessageService
    {
        public Task SendAsync(IdentityMessage message)
        {
            var mailMessage = new MailMessage();
            mailMessage.To.Add(new MailAddress(message.Destination));
            mailMessage.From = new MailAddress("Gcobani Mkontwana <ggcobani@gmail.com>");
            mailMessage.Subject = message.Subject;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = message.Body;

            using(var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = WebConfigurationManager.AppSettings["UserName"],
                    Password = Helper.Decrypt(WebConfigurationManager.AppSettings["UserPassword"])
                };
                smtp.Credentials = credential;
                smtp.Host = WebConfigurationManager.AppSettings["SMTPName"];
                smtp.Port = int.Parse(WebConfigurationManager.AppSettings["SMTPPort"]);
                smtp.EnableSsl = true;
                smtp.Send(mailMessage);
            }
            return Task.FromResult(0);
        } 
        }
    }

// Helper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.IO;
using System.Security.Cryptography;

namespace eNtsaTrainingRegistration.Helper
{
    public class Helper
    {
        private const string PassPhrase = "3pAc0j$_56K?_S7c9gS!";

        //Encrypt password.
        public static string Encrypt(string strValue)
        {
            byte[] results;
            UTF8Encoding uTF8 = new UTF8Encoding();
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] deskey = md5.ComputeHash(uTF8.GetBytes(PassPhrase));
            TripleDESCryptoServiceProvider desalg = new TripleDESCryptoServiceProvider();
            desalg.Key = deskey;
            desalg.Mode = CipherMode.ECB;
            desalg.Padding = PaddingMode.PKCS7;
            byte[] encrypt_data = uTF8.GetBytes(strValue);

            try
            {
                ICryptoTransform encrytor = desalg.CreateEncryptor();
                results = encrytor.TransformFinalBlock(encrypt_data, 0, encrypt_data.Length);
            }
            finally
            {
                desalg.Clear();
                md5.Clear();
            }
            return Convert.ToBase64String(results);
        }

        //Decrypt password.

        public static string Decrypt(string strValue)
        {
            byte[] results;
            UTF8Encoding uTF8 = new UTF8Encoding();
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] deskey = md5.ComputeHash(uTF8.GetBytes(PassPhrase));
            TripleDESCryptoServiceProvider desalg = new TripleDESCryptoServiceProvider();
            desalg.Key = deskey;
            desalg.Mode = CipherMode.ECB;
            desalg.Padding = PaddingMode.PKCS7;
            byte[] decrypt_data = Convert.FromBase64String(strValue);
            try
            {
                ICryptoTransform decryptor = desalg.CreateDecryptor();
                results = decryptor.TransformFinalBlock(decrypt_data, 0, decrypt_data.Length);
            }
            finally
            {
                desalg.Clear();
                md5.Clear();
            }
            return uTF8.GetString(results);
        }
Posted
Updated 26-Feb-20 23:15pm
Comments
gcogco10 27-Feb-20 5:01am    
I did use that assembly I am still facing the issue even now.

You need
C#
using eNtsaTrainingRegistration.Helper;
 
Share this answer
 
Your Helper class is in the namespace eNtsaTrainingRegistration.Helper so you need to either add the Helper namespace designation to your call,
C#
Password = Helper.Helper.Decrypt(WebConfigurationManager.AppSettings["UserPassword"])

or include a using statement for the full namespace.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900