Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

35 lines
1004 B

// ==========================================================================
// RandomHash.cs
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex Group
// All rights reserved.
// ==========================================================================
using System;
using System.Security.Cryptography;
using System.Text;
namespace Squidex.Infrastructure
{
public static class RandomHash
{
public static string New()
{
return Guid.NewGuid().ToString().Sha256Base64().Replace("+", "x");
}
public static string Sha256Base64(this string value)
{
using (var sha = SHA256.Create())
{
var bytesValue = Encoding.UTF8.GetBytes(value);
var bytesHash = sha.ComputeHash(bytesValue);
var result = Convert.ToBase64String(bytesHash);
return result;
}
}
}
}