Restore SEBPatch
This commit is contained in:
31
SafeExamBrowser.Configuration/Cryptography/HashAlgorithm.cs
Normal file
31
SafeExamBrowser.Configuration/Cryptography/HashAlgorithm.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using SafeExamBrowser.Configuration.Contracts.Cryptography;
|
||||
|
||||
namespace SafeExamBrowser.Configuration.Cryptography
|
||||
{
|
||||
public class HashAlgorithm : IHashAlgorithm
|
||||
{
|
||||
public string GenerateHashFor(string password)
|
||||
{
|
||||
using (var algorithm = new SHA256Managed())
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(password);
|
||||
var hash = algorithm.ComputeHash(bytes);
|
||||
var hashString = String.Join(String.Empty, hash.Select(b => b.ToString("x2")));
|
||||
|
||||
return hashString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user