Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 66c9793

Browse files
committed
Add SHA512 madness
1 parent e6d1f9e commit 66c9793

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.0.0</Version>
3+
<Version>2.1.0</Version>
44
</PropertyGroup>
55

66
<PropertyGroup>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// _ __ __
2+
// ___ ___ ___ _ __ __| | __ _ | \/ |
3+
// / __|/ __| / _ \| '_ \ / _` | / _` || |\/| |
4+
// \__ \\__ \| __/| | | || (_| || (_| || | | |
5+
// |___/|___/ \___||_| |_| \__,_| \__,_||_| |_|
6+
// |
7+
// Copyright 2021-2021 Łukasz "JustArchi" Domeradzki
8+
// Contact: [email protected]
9+
// |
10+
// Licensed under the Apache License, Version 2.0 (the "License");
11+
// you may not use this file except in compliance with the License.
12+
// You may obtain a copy of the License at
13+
// |
14+
// http://www.apache.org/licenses/LICENSE-2.0
15+
// |
16+
// Unless required by applicable law or agreed to in writing, software
17+
// distributed under the License is distributed on an "AS IS" BASIS,
18+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
// See the License for the specific language governing permissions and
20+
// limitations under the License.
21+
22+
using System;
23+
using System.Diagnostics.CodeAnalysis;
24+
using JetBrains.Annotations;
25+
using JustArchiNET.Madness.Helpers;
26+
27+
namespace JustArchiNET.Madness.SHA512Madness;
28+
29+
[MadnessType(EMadnessType.Replacement)]
30+
[PublicAPI]
31+
[SuppressMessage("ReSharper", "InconsistentNaming")]
32+
public static class SHA512 {
33+
/// <summary>
34+
/// Computes the hash of data using the SHA512 algorithm.
35+
/// </summary>
36+
/// <param name="source">The data to hash.</param>
37+
/// <returns>The hash of the data.</returns>
38+
/// <exception cref="ArgumentNullException">
39+
/// <paramref name="source" /> is <see langword="null" />.
40+
/// </exception>
41+
public static byte[] HashData(byte[] source) {
42+
if (source == null) {
43+
throw new ArgumentNullException(nameof(source));
44+
}
45+
46+
using System.Security.Cryptography.SHA512 hashAlgorithm = System.Security.Cryptography.SHA512.Create();
47+
48+
return hashAlgorithm.ComputeHash(source);
49+
}
50+
}

0 commit comments

Comments
 (0)