diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-04 13:08:49 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-04 13:08:49 -0600 |
| commit | e6e1b146185ee554c9646771f8f4a5b137c9ef58 (patch) | |
| tree | c4e797ccf3024b922b05b5f63769818d0f64ff0d /src | |
| parent | 9ba9581e3de9812db5f0b31e833db1bbc499c7bb (diff) | |
| download | slskd-e6e1b146185ee554c9646771f8f4a5b137c9ef58.tar.gz | |
add Random
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Cryptography/Random.cs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/slskd/Common/Cryptography/Random.cs b/src/slskd/Common/Cryptography/Random.cs new file mode 100644 index 00000000..94d4fa24 --- /dev/null +++ b/src/slskd/Common/Cryptography/Random.cs @@ -0,0 +1,35 @@ +// <copyright file="Random.cs" company="slskd Team"> +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// </copyright> + +namespace slskd.Cryptography +{ + using System.Security.Cryptography; + + public static class Random + { + public static byte[] GetBytes(int size) + { + var key = new byte[size]; + using (var generator = RandomNumberGenerator.Create()) + { + generator.GetBytes(key); + } + + return key; + } + } +} |
