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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:05:03+00:00 2026-05-15T06:05:03+00:00

Only part of the string is getting decrypted, i think it has to do

  • 0

Only part of the string is getting decrypted, i think it has to do with my encoding.

Here is what happens:

        string s = "The brown fox jumped over the green frog";
        string k = "urieurut";
        string enc = EncryptString(s, k);
        string dec = DecryptString(enc, k);

The RESULT is this: The brown fox juϼ㴘裴혽Ή⪻ㆉr th≸ g⟤een frog

public static string EncryptString(string stringToEncrypt, string encryptionKey)
{
    string encrypted = String.Empty;

    UnicodeEncoding UE = new UnicodeEncoding();
    byte[] key = UE.GetBytes(encryptionKey);

    RijndaelManaged RMCrypto = new RijndaelManaged();
    MemoryStream ms = new MemoryStream();
    CryptoStream cs = new CryptoStream(ms, RMCrypto.CreateEncryptor(key, key), CryptoStreamMode.Write);

    byte[] encryptedString = UE.GetBytes(stringToEncrypt);
    cs.Write(encryptedString, 0, encryptedString.Length);
    cs.FlushFinalBlock();
    cs.Close();

    encrypted = UE.GetString(ms.ToArray());
    return encrypted;
}

public static string DecryptString(string stringToDecrypt, string encryptionKey)
{
    string decrypted = String.Empty;

    UnicodeEncoding UE = new UnicodeEncoding();
    byte[] key = UE.GetBytes(encryptionKey);
    byte[] data = UE.GetBytes(stringToDecrypt);

    RijndaelManaged RMCrypto = new RijndaelManaged();
    MemoryStream ms = new MemoryStream();
    CryptoStream cs = new CryptoStream(ms, RMCrypto.CreateDecryptor(key, key), CryptoStreamMode.Write);
    cs.Write(data, 0, data.Length);
    cs.FlushFinalBlock();
    cs.Close();

    decrypted = UE.GetString(ms.ToArray());

    return decrypted;
}
  • 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-15T06:05:04+00:00Added an answer on May 15, 2026 at 6:05 am

    I solved my issue by using base64 string for the encryption – i may look at other options but i only needed these methods for a small amount of data, here is the final code:

    public static string EncryptString(string stringToEncrypt, string encryptionKey)
    {
        string encrypted = String.Empty;
        byte[] key = Encoding.Unicode.GetBytes(encryptionKey);
    
        RijndaelManaged RMCrypto = new RijndaelManaged();
        RMCrypto.Padding = PaddingMode.PKCS7;
        MemoryStream ms = new MemoryStream();
        CryptoStream cs = new CryptoStream(ms, RMCrypto.CreateEncryptor(key, key), CryptoStreamMode.Write);
    
        byte[] encryptedString = Encoding.ASCII.GetBytes(stringToEncrypt);
        cs.Write(encryptedString, 0, encryptedString.Length);
        cs.FlushFinalBlock();
        cs.Close();
    
        //encrypted = Encoding.ASCII.GetString(ms.ToArray());
        return Convert.ToBase64String(ms.ToArray());
    }
    
    public static string DecryptString(string stringToDecrypt, string encryptionKey)
    {
        string decrypted = String.Empty;
        byte[] key = Encoding.Unicode.GetBytes(encryptionKey);
        byte[] data = Convert.FromBase64String(stringToDecrypt);
    
        RijndaelManaged RMCrypto = new RijndaelManaged();
        RMCrypto.Padding = PaddingMode.PKCS7;
        MemoryStream ms = new MemoryStream();
        CryptoStream cs = new CryptoStream(ms, RMCrypto.CreateDecryptor(key, key), CryptoStreamMode.Write);
        cs.Write(data, 0, data.Length);
        cs.FlushFinalBlock();
        cs.Close();
    
        decrypted = Encoding.ASCII.GetString(ms.ToArray());
    
        return decrypted;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't need a Link but rather only the href= part of the ActionLink.
I'm an ASP.NET web part novice. I've built a few simple ones using only
The only thing I've found has been; .hang { text-indent: -3em; margin-left: 3em; }
I'd like to test if a regex will match part of a string at
I've only recently been getting involved with PHP/AJAX/jQuery and it seems to me that
I am getting a Method not found: 'Boolean MyCompany.LibraryAssembly.SomeFunction(System.String)' exception/error when running a VB.NET
Details: Only disable after user clicks the submit button, but before the posting back
Using only ANSI C, what is the best way to, with fair certainty, determine
The only nice way I've found is: import sys import os try: os.kill(int(sys.argv[1]), 0)
The only experience I have so far with a touchscreen interface was one where

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.