128bit decryption question?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • J.R

    #1

    128bit decryption question?

    The below code works if "Input" is the result of a read from a binary file.
    I want Input to be a literal string variable. When this is the case,
    received "Length of Data to Decrypt is Invalid" error.

    Any ideas appreciated.

    Thank you, John.

    arrResult = UTF8.GetBytes(I nput);

    MemoryStream stmDecrypted = new MemoryStream();

    cptTransform = tDesProvider.Cr eateDecryptor(a rrKeyBytes, arrIVBytes);

    CryptoStream stmCrypt = new CryptoStream(st mDecrypted, cptTransform,
    CryptoStreamMod e.Write);

    stmCrypt.Write( arrResult, 0, arrResult.Lengt h);

    stmCrypt.FlushF inalBlock();


    stmDecrypted.Po sition = 0;


    stmDecrypted.Re ad(arrResult, 0, Convert.ToInt32 (stmDecrypted.L ength));

    Output = UTF8.GetString( arrResult);


  • Jon Skeet [C# MVP]

    #2
    Re: 128bit decryption question?

    J.R <someone@somewh ere.com> wrote:[color=blue]
    > The below code works if "Input" is the result of a read from a binary file.
    > I want Input to be a literal string variable. When this is the case,
    > received "Length of Data to Decrypt is Invalid" error.[/color]

    Please post a short but complete program which demonstrates the
    problem. See
    http://www.pobox.com/~skeet/csharp/complete.html for what I mean by
    that.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...