Code Monkey home page Code Monkey logo

aes-interop-example's Introduction

aes-interop-example's People

Contributors

dinochiesa avatar

Watchers

 avatar  avatar  avatar

aes-interop-example's Issues

[Help] slowAES.decrypt in C#

Hi,

Please take a look here: https://stackoverflow.com/q/31912000/9248173

I'm trying to solve the problem in C# using .net framework cryptography and this is what try:

    public static string GenerateCookie(string script)
    {
        var split = script.Split(new[] { "toNumbers(\"", "\")" }, StringSplitOptions.RemoveEmptyEntries)
                    .Where(s => s.Length == 32)
                    .ToArray();

        if (split.Length != 3)
            return null;

        var key = StringToByteArray(split[0]);
        var iv = StringToByteArray(split[1]);
        var bytesIn = StringToByteArray(split[2]);

        RijndaelManaged rijndael = new RijndaelManaged();
        rijndael.KeySize = key.Length * 8;
        rijndael.Padding = PaddingMode.None;
        rijndael.Key = key;
        rijndael.IV = iv;
        rijndael.Mode = CipherMode.CBC;

        var decrypter = rijndael.CreateDecryptor();
        var decrypted = decrypter.TransformFinalBlock(bytesIn, 0, bytesIn.Length);

        decrypter.Dispose();
        rijndael.Dispose();

        var hex = BitConverter.ToString(decrypted).Replace("-", "");
        var expireTime = new string(script.Skip(script.IndexOf("expires="))
                                    .TakeWhile(c => c != ';')
                                    .ToArray())
                                    .Replace("expires=", string.Empty);

        if (string.IsNullOrEmpty(expireTime))
        {
            return null;
        }

        return string.Format("__test={0}; expires={1}; path=/", hex, expireTime);
    }

And not worked, Also PaddingMode.PKCS7 give's me "Padding is invalid and cannot be removed" error.

I think the problem should be crypto, Do i do decryption correctly ?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.