mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 07:04:57 +01:00
Chat Refactor (#79) [TGSDeploy]
* Chat refactor: Service changes * Settings migration * First pass at implementing the commandline * WIP irc modes * Wip * Fix it * Working * Fix dickscord * Some readme updates * Fixes * PMs are admin etc * Compiling * Final touches * Version bump to 3.0.86.0
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace TGServerService
|
||||
{
|
||||
@@ -45,6 +47,24 @@ namespace TGServerService
|
||||
}
|
||||
}
|
||||
|
||||
public static string EncryptData(byte[] data, out string sentropy)
|
||||
{
|
||||
// Generate additional entropy (will be used as the Initialization vector)
|
||||
byte[] entropy = new byte[20];
|
||||
using (var rng = new RNGCryptoServiceProvider())
|
||||
rng.GetBytes(entropy);
|
||||
|
||||
byte[] ciphertext = ProtectedData.Protect(data, entropy, DataProtectionScope.CurrentUser);
|
||||
|
||||
sentropy = Convert.ToBase64String(entropy, 0, entropy.Length);
|
||||
return Convert.ToBase64String(ciphertext, 0, ciphertext.Length);
|
||||
}
|
||||
|
||||
public static byte[] DecryptData(string data, string entropy)
|
||||
{
|
||||
return ProtectedData.Unprotect(Convert.FromBase64String(data), Convert.FromBase64String(entropy), DataProtectionScope.CurrentUser);
|
||||
}
|
||||
|
||||
public static void CopyDirectory(string sourceDirName, string destDirName, IList<string> ignore = null, bool ignoreIfNotExists = false)
|
||||
{
|
||||
// If the destination directory doesn't exist, create it.
|
||||
|
||||
Reference in New Issue
Block a user