-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTools.cs
23 lines (22 loc) · 858 Bytes
/
Tools.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Elephant
{
class Tools
{
public static string getHash(Object input)
{
// generate a unique id for an arbitrairy object
MemoryStream memoryStream = new MemoryStream();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(memoryStream, input);
System.Security.Cryptography.SHA1CryptoServiceProvider sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] hash = sha.ComputeHash(memoryStream.ToArray());
string str = Convert.ToBase64String(sha.Hash);
return str;
}
}
}