-
Notifications
You must be signed in to change notification settings - Fork 0
/
UsbStore.cs
59 lines (50 loc) · 1.31 KB
/
UsbStore.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Security.Cryptography;
using System.Text;
namespace WindowsUsb {
class UsbStore {
private string model = null;
private string path = null;
private string serialNumber = null;
private long size = 0;
// ====== GETTER ======
public string getHash(){
using(MD5 hash = MD5.Create()){
byte[] data = hash.ComputeHash(Encoding.UTF8.GetBytes(model + serialNumber));
StringBuilder builder = new StringBuilder();
for(int i = 0; i < data.Length; i++){
builder.Append(data[i].ToString("x2"));
}
return builder.ToString();
}
}
public string getPath(){
return path;
}
public string getSerialNumber(){
return serialNumber;
}
public string getModel(){
return model;
}
public long getSize(){
return size;
}
// ====== SETTER ======
public void setPath(string path){
this.path = path;
}
public void setSerialNumber(string serialNumber){
this.serialNumber = serialNumber;
}
public void setModel(string model){
this.model = model;
}
public void setSize(long size){
this.size = size;
}
public override string ToString(){
return String.Format("{0}:\n-Model: {1}\n-Path: {2}\n-SerialNumber: {3}\n-Size: {4} Bytes\n-Hash: {5}",this.GetType().FullName, model, path, serialNumber, size, getHash());
}
}
}