string str = "Hello world!"; byte[] utf8Bytes = Encoding.UTF8.GetBytes(str);
string plainText = "This is a secret message."; byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText); string base64EncodedText = Convert.ToBase64String(plainTextBytes);This example shows that the package library used is System.Text.Encoding, along with the use of the Convert class to convert the byte array to a base64-encoded string.