Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6352853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:18:13+00:00 2026-05-24T22:18:13+00:00

i am using Encoding and decoding : For Encoding: private string EncodeServerName(string ServerName) {

  • 0

i am using Encoding and decoding :

For Encoding:

private string EncodeServerName(string ServerName)
    {
      byte[] NameEncodein = new byte[ServerName.Length];
      NameEncodein = System.Text.Encoding.UTF8.GetBytes(ServerName);
      string EcodedName = Convert.ToBase64String(NameEncodein);
      return EcodedName;
    }

and Decoding:

     public string DecoAndGetServerName(string Servername)
     {
         System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
         System.Text.Decoder strDecoder = encoder.GetDecoder();
         byte[] to_DecodeByte = Convert.FromBase64String(Servername);
         int charCount = strDecoder.GetCharCount(to_DecodeByte, 0, to_DecodeByte.Length);
         char[] decoded_char = new char[charCount];
         strDecoder.GetChars(to_DecodeByte, 0, to_DecodeByte.Length, decoded_char,0);
         string Name = new string(decoded_char);

         return Name;
     }

I am sending ServerName:DEV-SQL1\SQL2008

It is encoded:REVWLVNRTDFcU1FMMjAwOA==

Again i want to decode but getting Exception:in line:

byte[] to_DecodeByte = Convert.FromBase64String(Servername);

Exception IS:

`The input is not a valid Base-64 string as it contains a non-base 64 character,

more than two padding characters, or a non-white space character among the padding characters.`

How to solve this issue.

Please Help Me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:18:13+00:00Added an answer on May 24, 2026 at 10:18 pm

    Your code seems way too complex :-), here is one that works:

    public static string EncodeServerName(string serverName)
    {
        return Convert.ToBase64String(Encoding.UTF8.GetBytes(serverName));
    }
    
    public static string DecodeServerName(string encodedServername)
    {
        return Encoding.UTF8.GetString(Convert.FromBase64String(encodedServername));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a link shortening service and I'm using base64 encoding/decoding of an incremented
Does Python have a built-in, simple way of encoding/decoding strings using a password? Something
I have the following text: We%27re%20proud%20to%20introduce%20the%20Amazing I'd like to remove the encoding using PHP,
I am decoding a file using the following method: string outFileName = zfoFileName.Replace(.zfo, _tmp.zfo);
Aside from using a hardware video encoding/decoding device, is there an easy was to
I'm writing an encoding/decoding .COM program using Huffman algorithm for dos 8086 (16-bit tasm
if encoding using escape(data) in javascript, how to decode it in server side? I
Some of my script are using different encoding, and when I try to combine
I want to display image using base64 encoding in IE using GWT If it
This is a general question about character encoding when using MD5 libraries in various

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.