Rijndael encryption from Action Script to C #

I am trying to use encryption between Action Script and C #

My task is to decrypt the following message in C #

f1ca22a365ba54c005c3eb599d84b19c354d26dcf475ab4be775b991ac97884791017b12471000def05bb77bfe9c3a97d44ef78c9449f12daf6e25b61ab1a281

It uses Rijndael encyption, ECB (Electronic Code Book) mode, Key: Pas5pr @se, 128 bit key size and block size.

I have a problem, I can’t do it, will someone help me with this?

+2
source share
3 answers

I came across this link, which accesses both C # and ActionScript for AES Rijndael encryption

http://ryoushin.com/cmerighi/en-us/42,2007-03-02/AES-Rijndael_with_ActionScript_and_ASP_Net.aspx

0

Rijndael Encryption, -. , :

using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

namespace CMS.Core.Domain
{
    /// <summary>
    /// Summary description for EncryptionManager
    /// </summary>
    public static class EncryptionManager
    {
        public static string EncryptRijndael(string value, string encryptionKey) {
            try {
                var key = Encoding.UTF8.GetBytes(encryptionKey); //must be 16 chars
                var rijndael = new RijndaelManaged {
                    BlockSize = 128,
                    IV = key,
                    KeySize = 128,
                    Key = key
                };

                var transform = rijndael.CreateEncryptor();
                using (var ms = new MemoryStream()) {
                    using (var cs = new CryptoStream(ms, transform, CryptoStreamMode.Write)) {
                        byte[] buffer = Encoding.UTF8.GetBytes(value);

                        cs.Write(buffer, 0, buffer.Length);
                        cs.FlushFinalBlock();
                        cs.Close();
                    }
                    ms.Close();
                    return Convert.ToBase64String(ms.ToArray());
                }
            }
            catch {
                return string.Empty;
            }
        }

        public static string DecryptRijndael(string value, string encryptionKey)
        {
            try
            {
                var key = Encoding.UTF8.GetBytes(encryptionKey); //must be 16 chars
                var rijndael = new RijndaelManaged
                                               {
                                                   BlockSize = 128,
                                                   IV = key,
                                                   KeySize = 128,
                                                   Key = key
                                               };

                var buffer = Convert.FromBase64String(value);
                var transform = rijndael.CreateDecryptor();
                string decrypted;
                using (var ms = new MemoryStream())
                {
                    using (var cs = new CryptoStream(ms, transform, CryptoStreamMode.Write))
                    {
                        cs.Write(buffer, 0, buffer.Length);
                        cs.FlushFinalBlock();
                        decrypted = Encoding.UTF8.GetString(ms.ToArray());
                        cs.Close();
                    }
                    ms.Close();
                }

                return decrypted;
            }
            catch
            {
                return null;
            }
        }
    }
}

, , , 9 , - 16- . , Rijndael, , 16 .

+7

Rijndael, IV ( , )

0

All Articles