// Copyright © 2017-2018 Atomic Software, LLC. All Rights Reserved.
// See LICENSE.md for full license information.

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

namespace Atom.Core.Extensions
{
    public static class StringExtensions
    {
        public static string ToMD5(this string input)
        {
            var Md5 = MD5.Create();
            var InputBytes = Encoding.ASCII.GetBytes(input);
            var Hash = Md5.ComputeHash(InputBytes);
            var Builder = new StringBuilder();

            foreach (var t in Hash)
            {
                Builder.Append(t.ToString("x2"));
            }

            return Builder.ToString();
        }
    }
}
