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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:02:00+00:00 2026-05-21T09:02:00+00:00

I have a encryption/decryption method that works just fine with one exception. When I

  • 0

I have a encryption/decryption method that works just fine with one exception. When I attempt to read in encrypted text from a text file and then decrypt it I get the following error.

Invalid character in a Base-64 string

The strange thing is if I just read the encrypted text into a textbox and then copy and pate it into another text box that decrypts used the same decryption method it works just fine. No errors and the decryption proceeds. I am listing the decryption method and method used to read in the text file below.

Decryption Method

   Public Shared Function DecryptUserString(ByRef cipheredText As String, ByRef password As String) As String
      Dim RijndaelManagedObj As New RijndaelManaged
      Dim RijndaelEncObj As ICryptoTransform, MD5Obj As New MD5CryptoServiceProvider
      Dim DecryptedBytes As Byte(), EncryptedData As Byte()
      Dim PasswordBytes As Byte() = New ASCIIEncoding().GetBytes(password)
      Dim UTF8Encoding As System.Text.Encoding = System.Text.Encoding.UTF8

      'A modified Base64 is sent with ~ and -  so it can be sent as a form post
      EncryptedData = Convert.FromBase64String(Replace(Replace(cipheredText, "~", "+"), "-", "="))

      RijndaelManagedObj.BlockSize = 128
      RijndaelManagedObj.KeySize = 128
      RijndaelManagedObj.Mode = CipherMode.ECB
      RijndaelManagedObj.Padding = PaddingMode.None
      RijndaelManagedObj.Key = MD5Obj.ComputeHash(PasswordBytes)
      RijndaelEncObj = RijndaelManagedObj.CreateDecryptor()

      DecryptedBytes = RijndaelEncObj.TransformFinalBlock(EncryptedData, 0, EncryptedData.Length)

      If DecryptedBytes.Length > 0 Then
         DecryptUserString = UTF8Encoding.GetString(DecryptedBytes, 0, DecryptedBytes.Length)
         If DecryptedBytes.Length = 0 Then DecryptUserString = New ASCIIEncoding().GetString(DecryptedBytes)
      Else
         DecryptUserString = ""
      End If
   End Function

Method to read text from file

  Private Function ReadText(ByVal TextFilePath As String) As String
    Using ReadStream As FileStream = File.OpenRead(TextFilePath)
      Dim FileTextBuilder As New StringBuilder()
      Dim DataTransit As Byte() = New Byte(ReadStream.Length) {}
      Dim DataEncoding As New UTF8Encoding(True)
      While ReadStream.Read(DataTransit, 0, DataTransit.Length) > 0
          FileTextBuilder.Append(DataEncoding.GetString(DataTransit))
      End While
      Return FileTextBuilder.ToString()
    End Using
  End Function
  • 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-21T09:02:00+00:00Added an answer on May 21, 2026 at 9:02 am

    Can’t you use File.ReadAllText() method to read the whole file and then decrypt the same way you do with textboxes?
    I know, if file is huge that’s not a good idea, but you can give it a try to see if file is well saved or if you’re reading it bad.

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

Sidebar

Related Questions

I have a legacy C++ module that offers encryption/decryption using the openssl library (DES
I have this function I am using to decrypt values that works fine on
We have an encryption service that we've exposed over net. tcp. Most of the
I have an encryption/copy protection question. I'm writing an application for a company that
So I have this black box authentication method, handed down to me from the
I have a single key encrypted HTTP Live Stream which decodes fine in Quicktime
I have a script that appends some rows to a table. One of the
My requirement is that I need simple encryption/decryption methods in C# to encrypt and
I have been tasked with decrypting a file in Java that has been encrypted
I have been doing some research on creating an encryption/decryption class for use in

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.