Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Bad Data

Bad Data

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravingcoder
    wrote on last edited by
    #1

    My experience with "Bad data" when trying to decrypt buffers using RSACryptoServiceProvider is incorrect block size. What else is possible?

    R 1 Reply Last reply
    0
    • R ravingcoder

      My experience with "Bad data" when trying to decrypt buffers using RSACryptoServiceProvider is incorrect block size. What else is possible?

      R Offline
      R Offline
      ravfingcoder
      wrote on last edited by
      #2

      Hi, having trouble decrypting a buffer using RSA. Did you find solution to the problem yet? Here's the code - I've highlighted the problem with "QUESTION" tags. Here's my code, please take a look. Thanks. using System; using System.Text; using System.Security.Cryptography; namespace tryRSA { /// /// Summary description for Class1. /// class Class1 { /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { //Main int index=0; int iterations=0; int blocksize=0; int KeySizeByte=0; byte [] btSecret; byte [] btEncryptedSecret; byte [] btDescrambledSecret; byte [] btPlainTxtToken; byte [] btEncryptedToken; string secret = "This is a long secret"; ASCIIEncoding AE = new ASCIIEncoding(); RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(); KeySizeByte = RSA.KeySize/8; blocksize = KeySizeByte -11; //QUESTION 1: I've been told that blocksize is equal Key size less 11 bytes. How'd you know that? Console.WriteLine("Key size: {0}", KeySizeByte); Console.WriteLine("blocksize: {0}", blocksize); btSecret = AE.GetBytes(secret); if(btSecret.Length % blocksize != 0) { iterations = btSecret.Length/blocksize +1; } else { iterations = btSecret.Length/blocksize; } index=0; btPlainTxtToken = new byte [blocksize]; btEncryptedSecret = new byte [iterations*blocksize]; for(int i=0; i

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups