0

I have a file encrypted with AES in python and its key is defined in code as:

key = '\x14\x15\xa2\xf6\xb6\x17\x4a\x58\xb6\x17\x4a\x58\xb6\x17\x4a\x58'
#print binascii.hexlify(key)
aes = AES.new(key, AES.MODE_ECB)

However my C# code takes key parameter as something like "skey = 1234512345678976"

private static void EncryptFile(string inputFile, string outputFile, string skey)
        {
            try
            {
                using (RijndaelManaged aes = new RijndaelManaged())
                {
                    byte[] key = ASCIIEncoding.UTF8.GetBytes(skey);
                    ....
                }
            }
         }

So, how can I decrypt these files according to the same key? What is the equivalent of python key in C#? I am using C# code lies in here: http://www.fluxbytes.com/csharp/encrypt-and-decrypt-files-in-c/

1 Answer 1

1

I don't think you want to do ASCIIEncoding.UTF8.GetBytes(skey), you need to treat the key as if it was a hex string and convert it as such. See:

How can I convert a hex string to a byte array?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.