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 8640191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:13:11+00:00 2026-06-12T11:13:11+00:00

Unfortunately, I have some code that does this: byte[] plainText = System.Text.Encoding.ASCII.GetBytes(ClearText); var btcipherText

  • 0

Unfortunately, I have some code that does this:

            byte[] plainText = System.Text.Encoding.ASCII.GetBytes(ClearText);
            var btcipherText = enc.Encrypt(plainText, btkey);
            System.Text.Encoding en = System.Text.Encoding.Default;
            return en.GetString(btcipherText);

Which is then saved to the database as a user’s password.

In mono, on Ubuntu 12.04, System.Text.Encoding.Default is System.Text.Encoding.UTF8, while on Windows 7, it seems to be System.Text.SBCSCodePageEncoding.

The password encryption/decryption code should never have been using System.Text.Encoding.Default, but this is inherited code. Looking in System.Text.Encoding, and having googled my problem extensively, I am unable to determine how I might decode this string with a standard encoding, and in this case on a Mono/Linux stack that lacks the original encoding.

I’ve also strangely not been able to find much information on System.Text.SBCSCodePageEncoding

When I try to decrypt a string stored with this encoding, I get the usual “Bad data” and “Invalid block size” Cryptographic exceptions.

Any information or suggestions are appreciated.

  • 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-06-12T11:13:12+00:00Added an answer on June 12, 2026 at 11:13 am

    Building on the other answer, given that you know which limited set of encodings are used to convert the byte[] to a string, build a utility (or build it into the app so that passwords are upgraded as they are used) that read and decodes the password back to a valid byte[] then store the byte[] as Base64 in the database.

    I see your also considering hashing the passwords, in this case and almost any other case if your dealing with a byte[] that doesn’t actually represent text, that you need to store/display as characters then base64 is always a good option.

    If you decide to hash the passwords make sure you use a HMAC style hashing system rather than just a plain password + salt, or even better grab a bcrypt implementation for .net.

    http://derekslager.com/blog/posts/2007/10/bcrypt-dotnet-strong-password-hashing-for-dotnet-and-mono.ashx

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

Sidebar

Related Questions

Unfortunately I inherited some code (c/c++) that does some string manipulation and now I
We have been given some code that does a URLRequest call which is really
Unfortunately I have to do some interaction with IBM's UniData database system. I am
I have some files that need to be sorted by name, unfortunately I can't
I see that this has been asked many times. But, unfortunately I have not
I have some jQuery code that, without it in the document it passes validation
OK, let me see if I can explain. I have some code that wraps
I have some code that I am trying to make it play nicely with
I have some code that is used to programmatically create a Document to send
I have some terribly written ASP.NET code that is just not working right (go

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.