Example #1
0
        public static async Task <string> Download(string url)
        {
            var hash     = md5.ComputeHash(Encoding.UTF8.GetBytes(url.Trim()));
            var fileName = string.Join("", hash.Select(x => x.ToString("x2")));

            return(await Download(url, fileName));
        }
Example #2
0
        public static Uri GetImageUrl(string email, int size)
        {
            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentException("Email must be a valid email address.", "email");
            }
            if (size <= 0)
            {
                throw new ArgumentException("Size must be greater than 0.", "size");
            }

            var hash       = md5.ComputeHash(Encoding.UTF8.GetBytes(email.Trim()));
            var hashString = string.Join("", hash.Select(x => x.ToString("x2")));

            return(new Uri("http://www.gravatar.com/avatar/" + hashString + ".jpg?s=" + size + "&d=mm"));
        }
Example #3
0
        public static Uri GetImageUrl(string email, int size)
        {
            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentException("Email must be a valid email address.", "email");
            }
            if (size <= 0)
            {
                throw new ArgumentException("Size must be greater than 0.", "size");
            }

            var hash = md5.ComputeHash(Encoding.ASCII.GetBytes(email.Trim()));
            //var hashString = string.Join("", hash.Select(x => x.ToString("x2")));
            StringBuilder hashString = new StringBuilder();

            for (int i = 0; i < hash.Length; i++)
            {
                hashString.Append(hash[i].ToString("x2"));
            }
            Debug.WriteLine($"https://www.gravatar.com/avatar/{hashString}?s=120&d=mm");
            return(new Uri($"https://www.gravatar.com/avatar/{hashString}?s=120&d=mm"));
        }