Skip to content

Commit

Permalink
feat: sending secure hash of connect key
Browse files Browse the repository at this point in the history
Using SHA256 to send key so that it isnt send a plain text, allows key to be used for simple passwords
  • Loading branch information
James-Frowen committed Oct 20, 2023
1 parent 02e52f0 commit 118b1b7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Assets/Mirage/Runtime/SocketLayer/ConnectKeyValidator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Security.Cryptography;
using System.Text;

namespace Mirage.SocketLayer
Expand Down Expand Up @@ -27,7 +28,12 @@ private static byte[] GetKeyBytes(string key)
key = $"Mirage V{version}";
}

return Encoding.ASCII.GetBytes(key);
var bytes = Encoding.ASCII.GetBytes(key);
using (var sha = SHA256.Create())
{
var hash = sha.ComputeHash(bytes);
return hash;
}
}
public ConnectKeyValidator(string key) : this(GetKeyBytes(key))
{
Expand Down

0 comments on commit 118b1b7

Please sign in to comment.