Пример #1
0
        } // End Sub GetIV

        //public static void SetKey(ref string strInputKey)
        //{
        //    strKey = strInputKey;
        //} // End Sub SetKey


        //public static void SetIV(ref string strInputIV)
        //{
        //    strIV = strInputIV;
        //} // End Sub SetIV


        public static string GenerateKey()
        {
            System.Security.Cryptography.RijndaelManaged objRijndael = new System.Security.Cryptography.RijndaelManaged();

            objRijndael.GenerateKey();
            objRijndael.GenerateIV();

            byte[] bIV  = objRijndael.IV;
            byte[] bKey = objRijndael.Key;
            objRijndael.Clear();

            return("IV: " + ByteArrayToHexString(bIV) + Environment.NewLine + "Key: " + ByteArrayToHexString(bKey));
        } // End Function GenerateKey
Пример #2
0
        public static String GetCypherKey()
        {
            System.Security.Cryptography.RijndaelManaged aesEncryption = new System.Security.Cryptography.RijndaelManaged();
            aesEncryption.KeySize   = 256;
            aesEncryption.BlockSize = 128;
            aesEncryption.Mode      = System.Security.Cryptography.CipherMode.CBC;
            aesEncryption.Padding   = System.Security.Cryptography.PaddingMode.PKCS7;
            aesEncryption.GenerateIV();
            Byte[] iv = aesEncryption.IV;
            aesEncryption.GenerateKey();
            Byte[] k = aesEncryption.Key;

            Byte[] key = new Byte[16 + 32];
            Array.Copy(iv, 0, key, 0, 16);
            Array.Copy(k, 0, key, 16, 32);

            return(Convert.ToBase64String(key));
        }
        public static string GenerateKey()
        {
            System.Security.Cryptography.RijndaelManaged objRijndael = new System.Security.Cryptography.RijndaelManaged();

            objRijndael.GenerateKey();
            objRijndael.GenerateIV();

            byte[] bIV = objRijndael.IV;
            byte[] bKey = objRijndael.Key;
            objRijndael.Clear();

            return "IV: " + ByteArrayToHexString(bIV) + System.Environment.NewLine + "Key: " + ByteArrayToHexString(bKey);
        }
Пример #4
0
        //[MenuItem("Hugula AES/GenerateKey", false, 12)]
        public static void GenerateKey()
        {
            using (System.Security.Cryptography.RijndaelManaged myRijndael = new System.Security.Cryptography.RijndaelManaged())
            {

                myRijndael.GenerateKey();
                byte[] Key = myRijndael.Key;

                KeyVData KeyScri = ScriptableObject.CreateInstance<KeyVData>();
                KeyScri.KEY = Key;
                AssetDatabase.CreateAsset(KeyScri, Path.Combine(ConfigPath, "I81.asset"));

                Debug.Log("key Generate " + Key.Length);

            }
        }