MD5CryptoServiceProvider' does not exist in the namespace 'System.Security.Cryptography. HELP PLEASE

Hey guys…

I “had” everything working fine… as a matter of fact it is working fine in Unity… but, when I try to buil the package for the Windows Metro Store, I received that error and it does not allow me to build it…

I think it is because of the update in the APIs for .net and Windows… but does anyone of you already had this issue and was able to fix it?

Here is the “not working” code

using UnityEngine;
using System.Collections;
using UnityEngine.Windows;


using System.Text;
using System.Security.Cryptography;


public static class Md5Functions
{
    public static string Md5Sum(string strToEncrypt)
    {
        System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
        byte[] bytes = ue.GetBytes(strToEncrypt);

        // encrypt bytes
        System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
        byte[] hashBytes = md5.ComputeHash(bytes);

        // Convert the encrypted bytes back to a string (base 16)
        string hashString = "";

        for (int i = 0; i < hashBytes.Length; i++)
        {
            hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
        }

        return hashString.PadLeft(32, '0');
    }
}

Thanks!!!

Here is the answer (one of many) found by using that fancy “Search” bar at the top of the forums. :slight_smile:

The thread originates with how to use it on Windows Store Apps and you’ll find a couple of replies from myself with an implementation for Windows Phone as well.