FAQ
I was given a C# program with the following function:

  public static byte[] Decrypt( byte[] data, byte[] keyIV )
     {
       var rm = new RijndaelManaged {Padding = PaddingMode.PKCS7};
       ICryptoTransform decryptor = rm.CreateDecryptor( keyIV, keyIV );
       using( var msDecrypt = new MemoryStream( ) )
       {
         using( var decStream = new CryptoStream( msDecrypt, decryptor,
CryptoStreamMode.Write ) )
         {
           decStream.Write( data, 0, data.Length );
           decStream.FlushFinalBlock( );
           return msDecrypt.ToArray( );
         }
       }
     }


What would be the equivalent GO crypto code to (given a slice of bytes from
an encrypted file and the IV slice of bytes) that would decrypt the file?

I'm assuming here it would be the crypto/aes package, but not sure how to
set the padding mode, etc.

Thanks!

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Brian Hatfield at Mar 2, 2016 at 9:04 pm
    Perhaps this will help? https://godoc.org/github.com/fullsailor/pkcs7
    On Wed, Mar 2, 2016 at 3:45 PM, sc28 wrote:

    I was given a C# program with the following function:

    public static byte[] Decrypt( byte[] data, byte[] keyIV )
    {
    var rm = new RijndaelManaged {Padding = PaddingMode.PKCS7};
    ICryptoTransform decryptor = rm.CreateDecryptor( keyIV, keyIV );
    using( var msDecrypt = new MemoryStream( ) )
    {
    using( var decStream = new CryptoStream( msDecrypt, decryptor,
    CryptoStreamMode.Write ) )
    {
    decStream.Write( data, 0, data.Length );
    decStream.FlushFinalBlock( );
    return msDecrypt.ToArray( );
    }
    }
    }


    What would be the equivalent GO crypto code to (given a slice of bytes
    from an encrypted file and the IV slice of bytes) that would decrypt the
    file?

    I'm assuming here it would be the crypto/aes package, but not sure how to
    set the padding mode, etc.

    Thanks!

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Sc28 at Mar 3, 2016 at 7:01 pm
    Thanks - I'll look at this.
    On Wednesday, March 2, 2016 at 4:04:55 PM UTC-5, Brian Hatfield wrote:

    Perhaps this will help? https://godoc.org/github.com/fullsailor/pkcs7

    On Wed, Mar 2, 2016 at 3:45 PM, sc28 <scohen...@gmail.com <javascript:>>
    wrote:
    I was given a C# program with the following function:

    public static byte[] Decrypt( byte[] data, byte[] keyIV )
    {
    var rm = new RijndaelManaged {Padding = PaddingMode.PKCS7};
    ICryptoTransform decryptor = rm.CreateDecryptor( keyIV, keyIV );
    using( var msDecrypt = new MemoryStream( ) )
    {
    using( var decStream = new CryptoStream( msDecrypt, decryptor,
    CryptoStreamMode.Write ) )
    {
    decStream.Write( data, 0, data.Length );
    decStream.FlushFinalBlock( );
    return msDecrypt.ToArray( );
    }
    }
    }


    What would be the equivalent GO crypto code to (given a slice of bytes
    from an encrypted file and the IV slice of bytes) that would decrypt the
    file?

    I'm assuming here it would be the crypto/aes package, but not sure how to
    set the padding mode, etc.

    Thanks!

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 2, '16 at 8:45p
activeMar 3, '16 at 7:01p
posts3
users2
websitegolang.org

2 users in discussion

Sc28: 2 posts Brian Hatfield: 1 post

People

Translate

site design / logo © 2022 Grokbase