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

  • SEARCH
  • Home
  • 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 7413713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:56:52+00:00 2026-05-29T06:56:52+00:00

Here is my method: public static string GenerateRandomString(int bytes) { var rng = new

  • 0

Here is my method:

public static string GenerateRandomString(int bytes)
{
    var rng = new RNGCryptoServiceProvider();
    var randomBytes = new byte[bytes];
    rng.GetBytes(randomBytes);
    return Convert.ToBase64String(randomBytes);
}

Every value generated:

i.e.:

Qcr6OgNxkGzVebNl00Dtk7yCaz64owUx7pKEhl1Ogn4=
IGFLQB0OrReDB3P6nuZgqZIkTwTtch9Fk3Rx/DL4CgI=
UAJwLwIPYEJ9SzMAK/EMiUJ/DHhmfy6UVMM5MU6Dcpg=

always ends with “=” – why is this?

I’m sending this as a random string for a password reset email and am having issues with Microsoft Outlook not picking up the = at the end of the link. Is anyone aware of a way around this without simply chopping off the last character of the string?

  • 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-29T06:56:53+00:00Added an answer on May 29, 2026 at 6:56 am

    It has to do with the number of bytes returned. The = is used as padding for base64.

    EDIT

    Using your algorithm I generated strings using between 1 and 20 bytes, printing 1 result per line. As you can see, some strings end with equal signs, others do not.

    Ng==
    HAo=
    g+h1
    pdR+cQ==
    z5bFWwc=
    BilTQWCU
    kXo96Jilxw==
    7jc16UHgbGc=
    DnLzoSDUNVfQ
    6MwGWLD3ZcbfZA==
    hADhg4HFdMVi1n0=
    cWm2HEKs48VaoYgl
    TrwxX20FmEs7o8u2ag==
    WLORuUzewYDB18XFAcc=
    tSnvFVVm/NZ2tkXJnB6V
    McUWf0mAmM5/0Upu+eYd+w==
    Eln3QPMr2VjXt4e3GsZuOXo=
    DBYLTG3fDbMC5I1bnYmG/NxH
    KgGhxdZjmjUypsqnbQUMCJzVrQ==
    yI+3sFdzBX4Xfb2u6xuzQdS9II0=
    

    EDIT #2

    I realized that I explained why the = occurs, but never suggested another way to generate your URL parameter. One such way is the System.Web.HttpServerUtility.UrlTokenEncode() method which converts an array of bytes to an url-friendly format. To convert the string back to an array of bytes, use the System.Web.HttpServerUtility.UrlTokenDecode() method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's the method: public static int chooseStrat () { String[] strats = new String[1]
Here is my method: public static MethodCallExpression ClonePropertyAssignmentLambda<T>(Expression source, string property) { var targetExp
Here's the method: public static String CPUcolor () { System.out.println (What color am I?)
Here's my extension method for invoke on a control: public static void Invoke<T>(this T
I have a simple static method : public static <U> U findStuff(String id) {
This method: public static string[] getKeywords(string filename) { string[] keywords = XElement.Load(filename).Elements(Keyword).Attributes(name).Select(n => n.Value).ToArray
I have this extension method: public static string GetValueFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>>
On my front end, I have following functions: method to encrypt: public static string
Consider the following code: string propertyName; var dateList = new List<DateTime>() { DateTime.Now };
I am using Ladislav Mrnka's extension method: public static IQueryable<T> IncludeMultiple<T>(this IQueryable<T> query, params

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.