diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-10-17 08:59:57 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-17 08:59:57 -0500 |
| commit | 352def9012790ab97252715697291ba4c0ebec01 (patch) | |
| tree | 0b8d6e2340ce40818ddbbea2de0db4019b5e45a3 /tests | |
| parent | 593308d4e786cd569e3a683f5b02b8f13aa39b23 (diff) | |
| parent | 9379a1fa3af07bab44b81752fe808cb9ca94be7a (diff) | |
| download | slskd-352def9012790ab97252715697291ba4c0ebec01.tar.gz | |
Merge pull request #697 from slskd/agent
Add the ability to 'network' multiple copies of slskd together (enable remote shares)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/slskd.Tests.Unit/Common/Cryptography/AesTests.cs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/slskd.Tests.Unit/Common/Cryptography/AesTests.cs b/tests/slskd.Tests.Unit/Common/Cryptography/AesTests.cs new file mode 100644 index 00000000..c6c9be94 --- /dev/null +++ b/tests/slskd.Tests.Unit/Common/Cryptography/AesTests.cs @@ -0,0 +1,33 @@ +namespace slskd.Tests.Unit.Common.Cryptography +{ + using System.Text; + using slskd.Cryptography; + using Xunit; + + public class AesTests + { + [Fact] + public void Generates_Random_Keys_Of_Expected_Length() + { + var key = Aes.GenerateRandomKey(); + Assert.Equal(48, key.Length); + } + + [Fact] + public void Encrypts_And_Decrypts() + { + var plainText = "hello, world!"; + var plainBytes = Encoding.UTF8.GetBytes(plainText); + + var key = Aes.GenerateRandomKey(); + + var encryptedBytes = Aes.Encrypt(plainBytes, key); + + var decryptedBytes = Aes.Decrypt(encryptedBytes, key); + + var decryptedText = Encoding.UTF8.GetString(decryptedBytes); + + Assert.Equal(plainText, decryptedText); + } + } +} |
