Hack Forums
[C#] UTF8-String to ASCII (Decode and Encode) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] UTF8-String to ASCII (Decode and Encode) (/showthread.php?tid=6044140)



UTF8-String to ASCII (Decode and Encode) - Fun Vidos - Jan 26, 2020

Hi everyone, I have some stein like that
password(“password goes here”);
And I need to encrypt this string to ASCII like that
var encode(function)
password(decode((“ascii goes here)));
Thanks everyone to answers


RE: UTF8-String to ASCII (Decode and Encode) - MavenGradle - Jan 26, 2020

As I'm sure you're aware, the default string reference type consists of UTF-16 encoded data and not UTF-8. This is true for both the .NET Framework and .NET Core. For more information, please visit the official documentation here:
https://docs.microsoft.com/en-us/dotnet/api/system.string?view=netframework-4.8

In order to retrieve ASCII encoded data from a string in C#, one can utilize:
Code
Encoding.ASCII.GetBytes(value);

For more information, please visit the official documentation here:
https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding.ascii?view=netframework-4.8


RE: UTF8-String to ASCII (Decode and Encode) - Fun Vidos - Jan 27, 2020

(Jan 26, 2020 08:54 AM)MavenGradle Wrote:  As I'm sure you're aware, the default string reference type consists of UTF-16 encoded data and not UTF-8. This is true for both the .NET Framework and .NET Core. For more information, please visit the official documentation here:
https://docs.microsoft.com/en-us/dotnet/api/system.string?view=netframework-4.8

In order to retrieve ASCII encoded data from a string in C#, one can utilize:
Code
Encoding.ASCII.GetBytes(value);

For more information, please visit the official documentation here:
https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding.ascii?view=netframework-4.8
Thank you so much