aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs')
-rw-r--r--Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs b/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
new file mode 100644
index 000000000..3948ae1c4
--- /dev/null
+++ b/Software/Visual_Studio/Web/Tango.MachineService/Security/RefreshTokenEncoder.cs
@@ -0,0 +1,26 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Tango.Core.Cryptography;
+
+namespace Tango.MachineService.Security
+{
+ public class RefreshTokenEncoder<T>
+ {
+ public String Encode(T obj)
+ {
+ String str = obj.ToJsonString();
+ Rfc2898Cryptographer crypt = new Rfc2898Cryptographer();
+ return crypt.Encrypt(str);
+ }
+
+ public T Decode(String token)
+ {
+ Rfc2898Cryptographer crypt = new Rfc2898Cryptographer();
+ String str = crypt.Decrypt(token);
+ return JsonConvert.DeserializeObject<T>(str);
+ }
+ }
+} \ No newline at end of file