The next generation of the Teknik Services. Written in ASP.NET.
https://www.teknik.io/
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.
33 lines
811 B
33 lines
811 B
using System; |
|
using System.Collections.Generic; |
|
using System.IO; |
|
using System.Linq; |
|
using System.Security.Cryptography; |
|
using System.Text; |
|
|
|
namespace Teknik.Utilities.Cryptography |
|
{ |
|
public class SHA1 |
|
{ |
|
public static string Hash(string text) |
|
{ |
|
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(text))) |
|
{ |
|
return Hash(ms); |
|
} |
|
} |
|
|
|
public static string Hash(Stream stream) |
|
{ |
|
var hash = default(string); |
|
using (var algo = System.Security.Cryptography.SHA1.Create()) |
|
{ |
|
var hashBytes = algo.ComputeHash(stream); |
|
|
|
// Return as hexadecimal string |
|
hash = hashBytes.ToHex(); |
|
} |
|
return hash; |
|
} |
|
} |
|
}
|
|
|