Пример #1
0
        //----------------------------------------------------------------------------------------------------
        public static string RandomBase64(int min, int max)
        {
            int i = 32;

            eval("i = Math.floor(Math.random()*(max-min+1)+min);");
            var tmp = AESLogic.CryptoJS_lib_WordArray_random(i);

            return(AESLogic.CryptoJS_enc_Base64_stringify(tmp));
        }
Пример #2
0
        //----------------------------------------------------------------------------------------------------
        public static AESKeyInfo CreateNewAES()
        {
            var rtn = new AESKeyInfo();

            rtn.A = RandomBase64(1, 23);
            rtn.B = RandomBase64(0, 11);
            rtn.C = RandomBase64(0, 11);
            rtn.D = RandomBase64(1, 23);

            rtn.Pass = RandomBase64(25, 30);

            var salt1 = AESLogic.CryptoJS_lib_WordArray_random(128 / 8);
            var key   = AESLogic.CryptoJS_PBKDF2(rtn.Pass, salt1, 128 / 32, 200);

            rtn.Key = "" + AESLogic.CryptoJS_enc_Base64_stringify(key);

            var salt2 = AESLogic.CryptoJS_lib_WordArray_random(128 / 8);
            var iv    = AESLogic.CryptoJS_PBKDF2(rtn.Pass, salt2, 128 / 32, 200);

            rtn.IV = "" + AESLogic.CryptoJS_enc_Base64_stringify(iv);

            return(rtn);
        }