diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-03-22 10:53:22 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2023-03-22 10:53:22 -0500 |
| commit | 5ce2af04031d4c6fd1f057226cd11598434d5c69 (patch) | |
| tree | 7b127f2fc14478e9f78923e82ac5e0e98982225d /src | |
| parent | 664b01cfc85d7c71ad40049bd2f2066916de456c (diff) | |
| download | slskd-5ce2af04031d4c6fd1f057226cd11598434d5c69.tar.gz | |
move Base62Extensions, add Base64Extensions
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Base62Extensions.cs (renamed from src/slskd/Common/Cryptography/Base62Extensions.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Common/Base64Extensions.cs | 48 |
2 files changed, 49 insertions, 1 deletions
diff --git a/src/slskd/Common/Cryptography/Base62Extensions.cs b/src/slskd/Common/Base62Extensions.cs index b9ab3a72..b0171299 100644 --- a/src/slskd/Common/Cryptography/Base62Extensions.cs +++ b/src/slskd/Common/Base62Extensions.cs @@ -27,7 +27,7 @@ */ // <auto-generated /> -- suppress analysis -namespace slskd.Cryptography +namespace slskd { using System; using System.Collections.Generic; diff --git a/src/slskd/Common/Base64Extensions.cs b/src/slskd/Common/Base64Extensions.cs new file mode 100644 index 00000000..6eaf2dff --- /dev/null +++ b/src/slskd/Common/Base64Extensions.cs @@ -0,0 +1,48 @@ +// <copyright file="Base64Extensions.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 +{ + using System; + using System.Text; + + /// <summary> + /// Base 64 extensions. + /// </summary> + public static class Base64Extensions + { + /// <summary> + /// Encode this string in Base 64. + /// </summary> + /// <param name="str">The string to encode.</param> + /// <returns>The encoded string.</returns> + public static string ToBase64(this string str) + { + return Convert.ToBase64String(Encoding.UTF8.GetBytes(str)); + } + + /// <summary> + /// Decode this string from Base 64. + /// </summary> + /// <param name="str">The string to decode.</param> + /// <returns>The decoded string.</returns> + public static string FromBase64(this string str) + { + return Encoding.UTF8.GetString(Convert.FromBase64String(str)); + } + } +}
\ No newline at end of file |
