精华内容
最热下载
问答
  • 5星
    21.17MB qc_id_01 2021-07-29 12:05:14
  • 48KB slavewh 2020-02-10 14:23:40
  • 54KB weixin_43986579 2019-11-20 09:22:15
  • 68KB zhshteng 2018-04-14 01:50:23
  • 5星
    29KB ty840320 2008-04-16 17:27:02
  • 66KB weixin_40292092 2019-03-14 23:46:17
  • 672KB atulss 2020-06-12 13:52:19
  • 65KB landongming1987 2021-02-06 21:00:18
  • 61KB ye09518 2019-06-12 10:17:28
  • 62KB gouyue 2011-11-04 18:56:49
  • 8KB wawzymu 2018-08-01 18:00:13
  • 介绍 高级加密标准(Advanced Encryption Standard)是在2001年赢得美国国家标准技术研究院(NIST)的标准化加密算法搜索的算法。2002年,它被美国政府采纳为加密标准。 它基于Rijndael算法。 即使它是由NIST选择的...

    介绍

    高级加密标准(Advanced Encryption Standard)是在2001年赢得美国国家标准技术研究院(NIST)的标准化加密算法搜索的算法。2002年,它被美国政府采纳为加密标准。 它基于Rijndael算法。

    即使它是由NIST选择的,也不是可用的最强大的算法。 Twofish和Serpent算法都提供了更高的安全性。 选择AES是因为它在硬件或软件中实现时速度很快。

    什么是AES?

    AES是一种分组密码。 这意味着它一次加密一组字节。 在这种情况下,一次为16个字节。 通常,分组密码比流密码更安全,因为它们混淆了原始字节的位置。

    这是一个秘密密钥算法,这意味着它使用的密钥仅应由预期的发送者和接收者知道。 一个主要的问题是密钥的安全传输。 公钥密码学通过使用所谓的“硬”数学解决了这一问题,其中在一个方向上的计算很容易,而在相反方向上的求解则需要更长的时间。 一个例子是乘法与因式分解。 将两个数字相乘很容易,但是尝试找到用于获取该数字的两个数字会花费很长时间。 这种类型的“硬”数学使您可以传输发件人和收件人用来计算密钥的公共信息,而不必传输密钥。 那么为什么不只使用公钥加密呢? 它比秘密密钥加密要慢得多。

    密码学的一般缺陷

    密码学的一个弱点是可以使用蛮力将其入侵。 这意味着,只有在计算机尝试查找每个密码直到找到您使用的密码之前,该消息才可以保密。 您添加到密码中的每个字节意味着破解密码大约需要256倍的时间。 所以问题是,您需要多长时间才能将该消息保密?

    现在,这实际上并不是该算法的弱点。 一个实际的弱点是,许多算法都经过数学分析,可能会揭示出用于加密数据的密钥。 如果使用相同或相似的密钥提供足够的加密数据,将比使用蛮力更快地导致破解。 减轻这种情况的一种方法是使用随机数,初始化向量或盐。 它们基本上是与密钥一起使用的随机位,因此,即使您使用的是相同的密钥,每个消息也不相同,因为实际上随机位会更改所使用的密钥。

    这就是为什么您应该选择更长的密码以及为什么应该经常更改密码的原因。

    AES如何工作

    AES一次编码16个字节的数据,并根据其算法运行指定的轮数,具体取决于所需的强度位。 AES可以使用128位,194位或256位。 下面的示例实现是256位版本。

    它首先通过使用Rijndael密钥调度程序算法扩展原始密钥来创建圆形密钥。 然后,通过使用Rijndael S-box替换字节,移位字节,使用Galois字段扩散字节并添加回合密钥来加密该块。 在256位版本中,此操作执行14次。 它对每个16字节的数据块执行此操作。

    AES的特定弱点

    当前,最著名的针对AES的攻击是相关密钥攻击。 当您拥有使用相似密钥编码的密文时,即当您使用密码“ Password1”对文本进行编码,然后使用密码“ Password2”对文本进行编码时,就会发生相关密钥攻击。 这是由于AES的简单密钥调度程序。 但是,这种攻击是不可行的,并且在使用256位版本的AES时将花费太多时间而无用。

    AES的示例实现

    此功能可在许多VB实现中使用。 它甚至可以在Visual Basic脚本中工作,并且实际上是专门为VBScript编码的。 但是它应该可以直接移植到VBA。 我根据美国国家标准技术研究院的测试文件验证了结果。 以下功能用于加密文件,但可以修改以接受其他数据。

    此实现内联了许多使实现更易于阅读的功能。 这样做是为了提高速度。 它也以电子密码本模式(ECM)运行,这是最不安全的模式,但最容易理解和实施。 我将使用密码块链接模式(这是推荐的实现),并在完成后发布代码。

    基本上,ECM不会对每个块进行编码,因此不会发生任何变化,因此,如果对同一块进行编码,则结果将相同。 CBC通过将生成的密文与下一个明文块进行异或来解决此问题。 因此,即使同一块被编码两次,结果也会有所不同。

    Sub AES(sFile)
        Dim sbox, sboxinv, rcon
        Dim g2, g3, g9, g11, g13, g14 
        g2 = Array( _
            &h00,&h02,&h04,&h06,&h08,&h0a,&h0c,&h0e,&h10,&h12,&h14,&h16,&h18,&h1a,&h1c,&h1e, _
            &h20,&h22,&h24,&h26,&h28,&h2a,&h2c,&h2e,&h30,&h32,&h34,&h36,&h38,&h3a,&h3c,&h3e, _
            &h40,&h42,&h44,&h46,&h48,&h4a,&h4c,&h4e,&h50,&h52,&h54,&h56,&h58,&h5a,&h5c,&h5e, _
            &h60,&h62,&h64,&h66,&h68,&h6a,&h6c,&h6e,&h70,&h72,&h74,&h76,&h78,&h7a,&h7c,&h7e, _
            &h80,&h82,&h84,&h86,&h88,&h8a,&h8c,&h8e,&h90,&h92,&h94,&h96,&h98,&h9a,&h9c,&h9e, _
            &ha0,&ha2,&ha4,&ha6,&ha8,&haa,&hac,&hae,&hb0,&hb2,&hb4,&hb6,&hb8,&hba,&hbc,&hbe, _
            &hc0,&hc2,&hc4,&hc6,&hc8,&hca,&hcc,&hce,&hd0,&hd2,&hd4,&hd6,&hd8,&hda,&hdc,&hde, _
            &he0,&he2,&he4,&he6,&he8,&hea,&hec,&hee,&hf0,&hf2,&hf4,&hf6,&hf8,&hfa,&hfc,&hfe, _
            &h1b,&h19,&h1f,&h1d,&h13,&h11,&h17,&h15,&h0b,&h09,&h0f,&h0d,&h03,&h01,&h07,&h05, _
            &h3b,&h39,&h3f,&h3d,&h33,&h31,&h37,&h35,&h2b,&h29,&h2f,&h2d,&h23,&h21,&h27,&h25, _
            &h5b,&h59,&h5f,&h5d,&h53,&h51,&h57,&h55,&h4b,&h49,&h4f,&h4d,&h43,&h41,&h47,&h45, _
            &h7b,&h79,&h7f,&h7d,&h73,&h71,&h77,&h75,&h6b,&h69,&h6f,&h6d,&h63,&h61,&h67,&h65, _
            &h9b,&h99,&h9f,&h9d,&h93,&h91,&h97,&h95,&h8b,&h89,&h8f,&h8d,&h83,&h81,&h87,&h85, _
            &hbb,&hb9,&hbf,&hbd,&hb3,&hb1,&hb7,&hb5,&hab,&ha9,&haf,&had,&ha3,&ha1,&ha7,&ha5, _
            &hdb,&hd9,&hdf,&hdd,&hd3,&hd1,&hd7,&hd5,&hcb,&hc9,&hcf,&hcd,&hc3,&hc1,&hc7,&hc5, _
            &hfb,&hf9,&hff,&hfd,&hf3,&hf1,&hf7,&hf5,&heb,&he9,&hef,&hed,&he3,&he1,&he7,&he5) 
        g3 = Array( _
            &h00,&h03,&h06,&h05,&h0c,&h0f,&h0a,&h09,&h18,&h1b,&h1e,&h1d,&h14,&h17,&h12,&h11, _
            &h30,&h33,&h36,&h35,&h3c,&h3f,&h3a,&h39,&h28,&h2b,&h2e,&h2d,&h24,&h27,&h22,&h21, _
            &h60,&h63,&h66,&h65,&h6c,&h6f,&h6a,&h69,&h78,&h7b,&h7e,&h7d,&h74,&h77,&h72,&h71, _
            &h50,&h53,&h56,&h55,&h5c,&h5f,&h5a,&h59,&h48,&h4b,&h4e,&h4d,&h44,&h47,&h42,&h41, _
            &hc0,&hc3,&hc6,&hc5,&hcc,&hcf,&hca,&hc9,&hd8,&hdb,&hde,&hdd,&hd4,&hd7,&hd2,&hd1, _
            &hf0,&hf3,&hf6,&hf5,&hfc,&hff,&hfa,&hf9,&he8,&heb,&hee,&hed,&he4,&he7,&he2,&he1, _
            &ha0,&ha3,&ha6,&ha5,&hac,&haf,&haa,&ha9,&hb8,&hbb,&hbe,&hbd,&hb4,&hb7,&hb2,&hb1, _
            &h90,&h93,&h96,&h95,&h9c,&h9f,&h9a,&h99,&h88,&h8b,&h8e,&h8d,&h84,&h87,&h82,&h81, _
            &h9b,&h98,&h9d,&h9e,&h97,&h94,&h91,&h92,&h83,&h80,&h85,&h86,&h8f,&h8c,&h89,&h8a, _
            &hab,&ha8,&had,&hae,&ha7,&ha4,&ha1,&ha2,&hb3,&hb0,&hb5,&hb6,&hbf,&hbc,&hb9,&hba, _
            &hfb,&hf8,&hfd,&hfe,&hf7,&hf4,&hf1,&hf2,&he3,&he0,&he5,&he6,&hef,&hec,&he9,&hea, _
            &hcb,&hc8,&hcd,&hce,&hc7,&hc4,&hc1,&hc2,&hd3,&hd0,&hd5,&hd6,&hdf,&hdc,&hd9,&hda, _
            &h5b,&h58,&h5d,&h5e,&h57,&h54,&h51,&h52,&h43,&h40,&h45,&h46,&h4f,&h4c,&h49,&h4a, _
            &h6b,&h68,&h6d,&h6e,&h67,&h64,&h61,&h62,&h73,&h70,&h75,&h76,&h7f,&h7c,&h79,&h7a, _
            &h3b,&h38,&h3d,&h3e,&h37,&h34,&h31,&h32,&h23,&h20,&h25,&h26,&h2f,&h2c,&h29,&h2a, _
            &h0b,&h08,&h0d,&h0e,&h07,&h04,&h01,&h02,&h13,&h10,&h15,&h16,&h1f,&h1c,&h19,&h1a) 
        g9 = Array( _
            &h00,&h09,&h12,&h1b,&h24,&h2d,&h36,&h3f,&h48,&h41,&h5a,&h53,&h6c,&h65,&h7e,&h77, _
            &h90,&h99,&h82,&h8b,&hb4,&hbd,&ha6,&haf,&hd8,&hd1,&hca,&hc3,&hfc,&hf5,&hee,&he7, _
            &h3b,&h32,&h29,&h20,&h1f,&h16,&h0d,&h04,&h73,&h7a,&h61,&h68,&h57,&h5e,&h45,&h4c, _
            &hab,&ha2,&hb9,&hb0,&h8f,&h86,&h9d,&h94,&he3,&hea,&hf1,&hf8,&hc7,&hce,&hd5,&hdc, _
            &h76,&h7f,&h64,&h6d,&h52,&h5b,&h40,&h49,&h3e,&h37,&h2c,&h25,&h1a,&h13,&h08,&h01, _
            &he6,&hef,&hf4,&hfd,&hc2,&hcb,&hd0,&hd9,&hae,&ha7,&hbc,&hb5,&h8a,&h83,&h98,&h91, _
            &h4d,&h44,&h5f,&h56,&h69,&h60,&h7b,&h72,&h05,&h0c,&h17,&h1e,&h21,&h28,&h33,&h3a, _
            &hdd,&hd4,&hcf,&hc6,&hf9,&hf0,&heb,&he2,&h95,&h9c,&h87,&h8e,&hb1,&hb8,&ha3,&haa, _
            &hec,&he5,&hfe,&hf7,&hc8,&hc1,&hda,&hd3,&ha4,&had,&hb6,&hbf,&h80,&h89,&h92,&h9b, _
            &h7c,&h75,&h6e,&h67,&h58,&h51,&h4a,&h43,&h34,&h3d,&h26,&h2f,&h10,&h19,&h02,&h0b, _
            &hd7,&hde,&hc5,&hcc,&hf3,&hfa,&he1,&he8,&h9f,&h96,&h8d,&h84,&hbb,&hb2,&ha9,&ha0, _
            &h47,&h4e,&h55,&h5c,&h63,&h6a,&h71,&h78,&h0f,&h06,&h1d,&h14,&h2b,&h22,&h39,&h30, _
            &h9a,&h93,&h88,&h81,&hbe,&hb7,&hac,&ha5,&hd2,&hdb,&hc0,&hc9,&hf6,&hff,&he4,&hed, _
            &h0a,&h03,&h18,&h11,&h2e,&h27,&h3c,&h35,&h42,&h4b,&h50,&h59,&h66,&h6f,&h74,&h7d, _
            &ha1,&ha8,&hb3,&hba,&h85,&h8c,&h97,&h9e,&he9,&he0,&hfb,&hf2,&hcd,&hc4,&hdf,&hd6, _
            &h31,&h38,&h23,&h2a,&h15,&h1c,&h07,&h0e,&h79,&h70,&h6b,&h62,&h5d,&h54,&h4f,&h46) 
        g11 = Array( _
            &h00,&h0b,&h16,&h1d,&h2c,&h27,&h3a,&h31,&h58,&h53,&h4e,&h45,&h74,&h7f,&h62,&h69, _
            &hb0,&hbb,&ha6,&had,&h9c,&h97,&h8a,&h81,&he8,&he3,&hfe,&hf5,&hc4,&hcf,&hd2,&hd9, _
            &h7b,&h70,&h6d,&h66,&h57,&h5c,&h41,&h4a,&h23,&h28,&h35,&h3e,&h0f,&h04,&h19,&h12, _
            &hcb,&hc0,&hdd,&hd6,&he7,&hec,&hf1,&hfa,&h93,&h98,&h85,&h8e,&hbf,&hb4,&ha9,&ha2, _
            &hf6,&hfd,&he0,&heb,&hda,&hd1,&hcc,&hc7,&hae,&ha5,&hb8,&hb3,&h82,&h89,&h94,&h9f, _
            &h46,&h4d,&h50,&h5b,&h6a,&h61,&h7c,&h77,&h1e,&h15,&h08,&h03,&h32,&h39,&h24,&h2f, _
            &h8d,&h86,&h9b,&h90,&ha1,&haa,&hb7,&hbc,&hd5,&hde,&hc3,&hc8,&hf9,&hf2,&hef,&he4, _
            &h3d,&h36,&h2b,&h20,&h11,&h1a,&h07,&h0c,&h65,&h6e,&h73,&h78,&h49,&h42,&h5f,&h54, _
            &hf7,&hfc,&he1,&hea,&hdb,&hd0,&hcd,&hc6,&haf,&ha4,&hb9,&hb2,&h83,&h88,&h95,&h9e, _
            &h47,&h4c,&h51,&h5a,&h6b,&h60,&h7d,&h76,&h1f,&h14,&h09,&h02,&h33,&h38,&h25,&h2e, _
            &h8c,&h87,&h9a,&h91,&ha0,&hab,&hb6,&hbd,&hd4,&hdf,&hc2,&hc9,&hf8,&hf3,&hee,&he5, _
            &h3c,&h37,&h2a,&h21,&h10,&h1b,&h06,&h0d,&h64,&h6f,&h72,&h79,&h48,&h43,&h5e,&h55, _
            &h01,&h0a,&h17,&h1c,&h2d,&h26,&h3b,&h30,&h59,&h52,&h4f,&h44,&h75,&h7e,&h63,&h68, _
            &hb1,&hba,&ha7,&hac,&h9d,&h96,&h8b,&h80,&he9,&he2,&hff,&hf4,&hc5,&hce,&hd3,&hd8, _
            &h7a,&h71,&h6c,&h67,&h56,&h5d,&h40,&h4b,&h22,&h29,&h34,&h3f,&h0e,&h05,&h18,&h13, _
            &hca,&hc1,&hdc,&hd7,&he6,&hed,&hf0,&hfb,&h92,&h99,&h84,&h8f,&hbe,&hb5,&ha8,&ha3) 
        g13 = Array( _
            &h00,&h0d,&h1a,&h17,&h34,&h39,&h2e,&h23,&h68,&h65,&h72,&h7f,&h5c,&h51,&h46,&h4b, _
            &hd0,&hdd,&hca,&hc7,&he4,&he9,&hfe,&hf3,&hb8,&hb5,&ha2,&haf,&h8c,&h81,&h96,&h9b, _
            &hbb,&hb6,&ha1,&hac,&h8f,&h82,&h95,&h98,&hd3,&hde,&hc9,&hc4,&he7,&hea,&hfd,&hf0, _
            &h6b,&h66,&h71,&h7c,&h5f,&h52,&h45,&h48,&h03,&h0e,&h19,&h14,&h37,&h3a,&h2d,&h20, _
            &h6d,&h60,&h77,&h7a,&h59,&h54,&h43,&h4e,&h05,&h08,&h1f,&h12,&h31,&h3c,&h2b,&h26, _
            &hbd,&hb0,&ha7,&haa,&h89,&h84,&h93,&h9e,&hd5,&hd8,&hcf,&hc2,&he1,&hec,&hfb,&hf6, _
            &hd6,&hdb,&hcc,&hc1,&he2,&hef,&hf8,&hf5,&hbe,&hb3,&ha4,&ha9,&h8a,&h87,&h90,&h9d, _
            &h06,&h0b,&h1c,&h11,&h32,&h3f,&h28,&h25,&h6e,&h63,&h74,&h79,&h5a,&h57,&h40,&h4d, _
            &hda,&hd7,&hc0,&hcd,&hee,&he3,&hf4,&hf9,&hb2,&hbf,&ha8,&ha5,&h86,&h8b,&h9c,&h91, _
            &h0a,&h07,&h10,&h1d,&h3e,&h33,&h24,&h29,&h62,&h6f,&h78,&h75,&h56,&h5b,&h4c,&h41, _
            &h61,&h6c,&h7b,&h76,&h55,&h58,&h4f,&h42,&h09,&h04,&h13,&h1e,&h3d,&h30,&h27,&h2a, _
            &hb1,&hbc,&hab,&ha6,&h85,&h88,&h9f,&h92,&hd9,&hd4,&hc3,&hce,&hed,&he0,&hf7,&hfa, _
            &hb7,&hba,&had,&ha0,&h83,&h8e,&h99,&h94,&hdf,&hd2,&hc5,&hc8,&heb,&he6,&hf1,&hfc, _
            &h67,&h6a,&h7d,&h70,&h53,&h5e,&h49,&h44,&h0f,&h02,&h15,&h18,&h3b,&h36,&h21,&h2c, _
            &h0c,&h01,&h16,&h1b,&h38,&h35,&h22,&h2f,&h64,&h69,&h7e,&h73,&h50,&h5d,&h4a,&h47, _
            &hdc,&hd1,&hc6,&hcb,&he8,&he5,&hf2,&hff,&hb4,&hb9,&hae,&ha3,&h80,&h8d,&h9a,&h97) 
        g14 = Array( _
            &h00,&h0e,&h1c,&h12,&h38,&h36,&h24,&h2a,&h70,&h7e,&h6c,&h62,&h48,&h46,&h54,&h5a, _
            &he0,&hee,&hfc,&hf2,&hd8,&hd6,&hc4,&hca,&h90,&h9e,&h8c,&h82,&ha8,&ha6,&hb4,&hba, _
            &hdb,&hd5,&hc7,&hc9,&he3,&hed,&hff,&hf1,&hab,&ha5,&hb7,&hb9,&h93,&h9d,&h8f,&h81, _
            &h3b,&h35,&h27,&h29,&h03,&h0d,&h1f,&h11,&h4b,&h45,&h57,&h59,&h73,&h7d,&h6f,&h61, _
            &had,&ha3,&hb1,&hbf,&h95,&h9b,&h89,&h87,&hdd,&hd3,&hc1,&hcf,&he5,&heb,&hf9,&hf7, _
            &h4d,&h43,&h51,&h5f,&h75,&h7b,&h69,&h67,&h3d,&h33,&h21,&h2f,&h05,&h0b,&h19,&h17, _
            &h76,&h78,&h6a,&h64,&h4e,&h40,&h52,&h5c,&h06,&h08,&h1a,&h14,&h3e,&h30,&h22,&h2c, _
            &h96,&h98,&h8a,&h84,&hae,&ha0,&hb2,&hbc,&he6,&he8,&hfa,&hf4,&hde,&hd0,&hc2,&hcc, _
            &h41,&h4f,&h5d,&h53,&h79,&h77,&h65,&h6b,&h31,&h3f,&h2d,&h23,&h09,&h07,&h15,&h1b, _
            &ha1,&haf,&hbd,&hb3,&h99,&h97,&h85,&h8b,&hd1,&hdf,&hcd,&hc3,&he9,&he7,&hf5,&hfb, _
            &h9a,&h94,&h86,&h88,&ha2,&hac,&hbe,&hb0,&hea,&he4,&hf6,&hf8,&hd2,&hdc,&hce,&hc0, _
            &h7a,&h74,&h66,&h68,&h42,&h4c,&h5e,&h50,&h0a,&h04,&h16,&h18,&h32,&h3c,&h2e,&h20, _
            &hec,&he2,&hf0,&hfe,&hd4,&hda,&hc8,&hc6,&h9c,&h92,&h80,&h8e,&ha4,&haa,&hb8,&hb6, _
            &h0c,&h02,&h10,&h1e,&h34,&h3a,&h28,&h26,&h7c,&h72,&h60,&h6e,&h44,&h4a,&h58,&h56, _
            &h37,&h39,&h2b,&h25,&h0f,&h01,&h13,&h1d,&h47,&h49,&h5b,&h55,&h7f,&h71,&h63,&h6d, _
            &hd7,&hd9,&hcb,&hc5,&hef,&he1,&hf3,&hfd,&ha7,&ha9,&hbb,&hb5,&h9f,&h91,&h83,&h8d) 
        sbox = Array( _
            &h63, &h7c, &h77, &h7b, &hf2, &h6b, &h6f, &hc5, &h30, &h01, &h67, &h2b, &hfe, &hd7, &hab, &h76, _
            &hca, &h82, &hc9, &h7d, &hfa, &h59, &h47, &hf0, &had, &hd4, &ha2, &haf, &h9c, &ha4, &h72, &hc0, _
            &hb7, &hfd, &h93, &h26, &h36, &h3f, &hf7, &hcc, &h34, &ha5, &he5, &hf1, &h71, &hd8, &h31, &h15, _
            &h04, &hc7, &h23, &hc3, &h18, &h96, &h05, &h9a, &h07, &h12, &h80, &he2, &heb, &h27, &hb2, &h75, _
            &h09, &h83, &h2c, &h1a, &h1b, &h6e, &h5a, &ha0, &h52, &h3b, &hd6, &hb3, &h29, &he3, &h2f, &h84, _
            &h53, &hd1, &h00, &hed, &h20, &hfc, &hb1, &h5b, &h6a, &hcb, &hbe, &h39, &h4a, &h4c, &h58, &hcf, _
            &hd0, &hef, &haa, &hfb, &h43, &h4d, &h33, &h85, &h45, &hf9, &h02, &h7f, &h50, &h3c, &h9f, &ha8, _
            &h51, &ha3, &h40, &h8f, &h92, &h9d, &h38, &hf5, &hbc, &hb6, &hda, &h21, &h10, &hff, &hf3, &hd2, _
            &hcd, &h0c, &h13, &hec, &h5f, &h97, &h44, &h17, &hc4, &ha7, &h7e, &h3d, &h64, &h5d, &h19, &h73, _
            &h60, &h81, &h4f, &hdc, &h22, &h2a, &h90, &h88, &h46, &hee, &hb8, &h14, &hde, &h5e, &h0b, &hdb, _
            &he0, &h32, &h3a, &h0a, &h49, &h06, &h24, &h5c, &hc2, &hd3, &hac, &h62, &h91, &h95, &he4, &h79, _
            &he7, &hc8, &h37, &h6d, &h8d, &hd5, &h4e, &ha9, &h6c, &h56, &hf4, &hea, &h65, &h7a, &hae, &h08, _
            &hba, &h78, &h25, &h2e, &h1c, &ha6, &hb4, &hc6, &he8, &hdd, &h74, &h1f, &h4b, &hbd, &h8b, &h8a, _
            &h70, &h3e, &hb5, &h66, &h48, &h03, &hf6, &h0e, &h61, &h35, &h57, &hb9, &h86, &hc1, &h1d, &h9e, _
            &he1, &hf8, &h98, &h11, &h69, &hd9, &h8e, &h94, &h9b, &h1e, &h87, &he9, &hce, &h55, &h28, &hdf, _
            &h8c, &ha1, &h89, &h0d, &hbf, &he6, &h42, &h68, &h41, &h99, &h2d, &h0f, &hb0, &h54, &hbb, &h16) 
        sboxinv = Array( _
            &h52, &h09, &h6a, &hd5, &h30, &h36, &ha5, &h38, &hbf, &h40, &ha3, &h9e, &h81, &hf3, &hd7, &hfb, _
            &h7c, &he3, &h39, &h82, &h9b, &h2f, &hff, &h87, &h34, &h8e, &h43, &h44, &hc4, &hde, &he9, &hcb, _
            &h54, &h7b, &h94, &h32, &ha6, &hc2, &h23, &h3d, &hee, &h4c, &h95, &h0b, &h42, &hfa, &hc3, &h4e, _
            &h08, &h2e, &ha1, &h66, &h28, &hd9, &h24, &hb2, &h76, &h5b, &ha2, &h49, &h6d, &h8b, &hd1, &h25, _
            &h72, &hf8, &hf6, &h64, &h86, &h68, &h98, &h16, &hd4, &ha4, &h5c, &hcc, &h5d, &h65, &hb6, &h92, _
            &h6c, &h70, &h48, &h50, &hfd, &hed, &hb9, &hda, &h5e, &h15, &h46, &h57, &ha7, &h8d, &h9d, &h84, _
            &h90, &hd8, &hab, &h00, &h8c, &hbc, &hd3, &h0a, &hf7, &he4, &h58, &h05, &hb8, &hb3, &h45, &h06, _
            &hd0, &h2c, &h1e, &h8f, &hca, &h3f, &h0f, &h02, &hc1, &haf, &hbd, &h03, &h01, &h13, &h8a, &h6b, _
            &h3a, &h91, &h11, &h41, &h4f, &h67, &hdc, &hea, &h97, &hf2, &hcf, &hce, &hf0, &hb4, &he6, &h73, _
            &h96, &hac, &h74, &h22, &he7, &had, &h35, &h85, &he2, &hf9, &h37, &he8, &h1c, &h75, &hdf, &h6e, _
            &h47, &hf1, &h1a, &h71, &h1d, &h29, &hc5, &h89, &h6f, &hb7, &h62, &h0e, &haa, &h18, &hbe, &h1b, _
            &hfc, &h56, &h3e, &h4b, &hc6, &hd2, &h79, &h20, &h9a, &hdb, &hc0, &hfe, &h78, &hcd, &h5a, &hf4, _
            &h1f, &hdd, &ha8, &h33, &h88, &h07, &hc7, &h31, &hb1, &h12, &h10, &h59, &h27, &h80, &hec, &h5f, _
            &h60, &h51, &h7f, &ha9, &h19, &hb5, &h4a, &h0d, &h2d, &he5, &h7a, &h9f, &h93, &hc9, &h9c, &hef, _
            &ha0, &he0, &h3b, &h4d, &hae, &h2a, &hf5, &hb0, &hc8, &heb, &hbb, &h3c, &h83, &h53, &h99, &h61, _
            &h17, &h2b, &h04, &h7e, &hba, &h77, &hd6, &h26, &he1, &h69, &h14, &h63, &h55, &h21, &h0c, &h7d) 
        rcon = Array( _
            &h8d, &h01, &h02, &h04, &h08, &h10, &h20, &h40, &h80, &h1b, &h36, &h6c, &hd8, &hab, &h4d, &h9a, _
            &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, &h6a, &hd4, &hb3, &h7d, &hfa, &hef, &hc5, &h91, &h39, _
            &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, &h25, &h4a, &h94, &h33, &h66, &hcc, &h83, &h1d, &h3a, _
            &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, &h08, &h10, &h20, &h40, &h80, &h1b, &h36, &h6c, &hd8, _
            &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, &h6a, &hd4, &hb3, &h7d, &hfa, &hef, _
            &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, &h25, &h4a, &h94, &h33, &h66, &hcc, _
            &h83, &h1d, &h3a, &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, &h08, &h10, &h20, &h40, &h80, &h1b, _
            &h36, &h6c, &hd8, &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, &h6a, &hd4, &hb3, _
            &h7d, &hfa, &hef, &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, &h25, &h4a, &h94, _
            &h33, &h66, &hcc, &h83, &h1d, &h3a, &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, &h08, &h10, &h20, _
            &h40, &h80, &h1b, &h36, &h6c, &hd8, &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, _
            &h6a, &hd4, &hb3, &h7d, &hfa, &hef, &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, _
            &h25, &h4a, &h94, &h33, &h66, &hcc, &h83, &h1d, &h3a, &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, _
            &h08, &h10, &h20, &h40, &h80, &h1b, &h36, &h6c, &hd8, &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, _
            &hc6, &h97, &h35, &h6a, &hd4, &hb3, &h7d, &hfa, &hef, &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, _
            &h61, &hc2, &h9f, &h25, &h4a, &h94, &h33, &h66, &hcc, &h83, &h1d, &h3a, &h74, &he8, &hcb) 
        Dim expandedKey, block(16), aesKey(32), i, isDone, j, isEncode
        Dim sPlain, sPass, sCipher, sTemp
        Dim oFile1, oFS, oFile2
        Dim x, r, y, temp(4), intTemp 
        Set oFS = CreateObject("Scripting.FileSystemObject")
        Set oFile1 = oFS.OpenTextFile(sFile, ForReading) 
        If Right(sFile, 4) <> ".enc" Then
            sFile = sFile & ".enc"
            oFS.CreateTextFile sFile, 2, True
            isEncode = True
        Else
            sFile = Left(sFile, Len(sFile) - 4) & ".unenc"
            oFS.CreateTextFile sFile, 2, True
            isEncode = False
        End If 
        Set oFile2 = oFS.OpenTextFile(sFile, ForWriting)
        Set oFS = Nothing 
        For i = 0 To (Len(oPW.Value) - 1)
            aesKey(i) = Asc(Mid(oPW.Value, i + 1, 1))
        Next 
        For i = Len(oPW.Value) To 31
            aesKey(i) = 0
        Next 
        expandedKey = expandKey(aesKey, sbox, rcon) 
        Do Until oFile1.AtEndOfStream
            sPlain = oFile1.Read(1024)
            sCipher = ""
            j = 0
            isDone = False 
            Do Until isDone
                sTemp = Mid(sPlain, j*16 + 1, 16) 
                If Len(sTemp) < 16 Then
                    For i = Len(sTemp) To 15
                        sTemp = sTemp & Chr(0)
                    Next
                End If 
                For i = 0 To 15
                    block(i) = Asc(Mid(sTemp, (i Mod 4) * 4 + (i \ 4) + 1, 1))
                Next 
                If (j + 1) * 16 >= Len(sPlain) Then
                    isDone = True
                End If 
                j = j + 1 
                If isEncode Then
                    r= 0
                    For i = 0 To 15
                        block(i) = block(i) Xor expandedKey((i Mod 4) * 4 + (i \ 4))
                    Next 
                    For x = 1 To 13
                        block(0) = sbox(block(0))
                        block(1) = sbox(block(1))
                        block(2) = sbox(block(2))
                        block(3) = sbox(block(3)) 
                        intTemp = sbox(block(4))
                        block(4) = sbox(block(5))
                        block(5) = sbox(block(6))
                        block(6) = sbox(block(7))
                        block(7) = intTemp 
                        intTemp = sbox(block(8))
                        block(8) = sbox(block(10))
                        block(10) = intTemp
                        intTemp = sbox(block(9))
                        block(9) = sbox(block(11))
                        block(11) = intTemp 
                        intTemp = sbox(block(12))
                        block(12) = sbox(block(15))
                        block(15) = sbox(block(14))
                        block(14) = sbox(block(13))
                        block(13) = intTemp 
                        r = x * 16
                        For i = 0 To 3
                            temp(0) = block(i)
                            temp(1) = block(i+4)
                            temp(2) = block(i+8)
                            temp(3) = block(i+12) 
                            block(i) = g2(temp(0)) Xor temp(3) Xor temp(2) Xor g3(temp(1)) Xor expandedKey(r+i*4)
                            block(i+4) = g2(temp(1)) Xor temp(0) Xor temp(3) Xor g3(temp(2)) Xor expandedKey(r+i*4+1)
                            block(i+8) = g2(temp(2)) Xor temp(1) Xor temp(0) Xor g3(temp(3)) Xor expandedKey(r+i*4+2)
                            block(i+12) = g2(temp(3)) Xor temp(2) Xor temp(1) Xor g3(temp(0)) Xor expandedKey(r+i*4+3)
                        Next
                    Next 
                    block(0) = sbox(block(0)) Xor expandedKey(224)
                    block(1) = sbox(block(1)) Xor expandedKey(228)
                    block(2) = sbox(block(2)) Xor expandedKey(232)
                    block(3) = sbox(block(3)) Xor expandedKey(236) 
                    intTemp = sbox(block(4)) Xor expandedKey(237)
                    block(4) = sbox(block(5)) Xor expandedKey(225)
                    block(5) = sbox(block(6)) Xor expandedKey(229)
                    block(6) = sbox(block(7)) Xor expandedKey(233)
                    block(7) = intTemp 
                    intTemp = sbox(block(8)) Xor expandedKey(234)
                    block(8) = sbox(block(10)) Xor expandedKey(226)
                    block(10) = intTemp
                    intTemp = sbox(block(9)) Xor expandedKey(238)
                    block(9) = sbox(block(11)) Xor expandedKey(230)
                    block(11) = intTemp 
                    intTemp = sbox(block(12)) Xor expandedKey(231)
                    block(12) = sbox(block(15)) Xor expandedKey(227)
                    block(15) = sbox(block(14)) Xor expandedKey(239)
                    block(14) = sbox(block(13)) Xor expandedKey(235)
                    block(13) = intTemp
                Else
                    block(0) = sboxinv(block(0) Xor expandedKey(224))
                    block(1) = sboxinv(block(1) Xor expandedKey(228))
                    block(2) = sboxinv(block(2) Xor expandedKey(232))
                    block(3) = sboxinv(block(3) Xor expandedKey(236)) 
                    intTemp = sboxinv(block(4) Xor expandedKey(225))
                    block(4) = sboxinv(block(7) Xor expandedKey(237))
                    block(7) = sboxinv(block(6) Xor expandedKey(233))
                    block(6) = sboxinv(block(5) Xor expandedKey(229))
                    block(5) = intTemp 
                    intTemp = sboxinv(block(8) Xor expandedKey(226))
                    block(8) = sboxinv(block(10) Xor expandedKey(234))
                    block(10) = intTemp
                    intTemp = sboxinv(block(9) Xor expandedKey(230))
                    block(9) = sboxinv(block(11) Xor expandedKey(238))
                    block(11) = intTemp 
                    intTemp = sboxinv(block(12) Xor expandedKey(227))
                    block(12) = sboxinv(block(13) Xor expandedKey(231))
                    block(13) = sboxinv(block(14) Xor expandedKey(235))
                    block(14) = sboxinv(block(15) Xor expandedKey(239))
                    block(15) = intTemp 
                    For x = 13 To 1 Step -1
                        r = x * 16 
                        For i = 0 To 3
                            temp(0) = block(i) Xor expandedKey(r+i*4)
                            temp(1) = block(i+4) Xor expandedKey(r+i*4+1)
                            temp(2) = block(i+8) Xor expandedKey(r+i*4+2)
                            temp(3) = block(i+12) Xor expandedKey(r+i*4+3) 
                            block(i) = g14(temp(0)) Xor g9(temp(3)) Xor g13(temp(2)) Xor g11(temp(1))
                            block(i+4) = g14(temp(1)) Xor g9(temp(0)) Xor g13(temp(3)) Xor g11(temp(2))
                            block(i+8) = g14(temp(2)) Xor g9(temp(1)) Xor g13(temp(0)) Xor g11(temp(3))
                            block(i+12) = g14(temp(3)) Xor g9(temp(2)) Xor g13(temp(1)) Xor g11(temp(0))
                        Next 
                        block(0) = sboxinv(block(0))
                        block(1) = sboxinv(block(1))
                        block(2) = sboxinv(block(2))
                        block(3) = sboxinv(block(3)) 
                        intTemp = sboxinv(block(4))
                        block(4) = sboxinv(block(7))
                        block(7) = sboxinv(block(6))
                        block(6) = sboxinv(block(5))
                        block(5) = intTemp 
                        intTemp = sboxinv(block(8))
                        block(8) = sboxinv(block(10))
                        block(10) = intTemp
                        intTemp = sboxinv(block(9))
                        block(9) = sboxinv(block(11))
                        block(11) = intTemp 
                        intTemp = sboxinv(block(12))
                        block(12) = sboxinv(block(13))
                        block(13) = sboxinv(block(14))
                        block(14) = sboxinv(block(15))
                        block(15) = intTemp
                    Next 
                    r= 0
                    For i = 0 To 15
                        block(i) = block(i) Xor expandedKey((i Mod 4) * 4 + (i \ 4))
                    Next
                End If 
                For i = 0 To 15
                    sCipher = sCipher & Chr(block((i Mod 4) * 4 + (i \ 4)))
                Next
            Loop 
            oFile2.Write sCipher
        Loop 
        oFile1.Close
        Set oFile1 = Nothing
        oFile2.Close
        Set oFile2 = Nothing
    End Sub 
    Function keyScheduleCore(ByVal row(), ByVal a, ByRef box(), ByRef rcon())
        Dim result(4), i 
        For i = 0 To 3
            result(i) = box(row((i + 5) Mod 4))
        Next 
        result(0) = result(0) Xor rcon(a)
        keyScheduleCore = result
    End Function 
    Function expandKey(ByRef key(), ByRef box(), ByRef rcon())
        Dim rConIter, temp, i, result(240) 
        ReDim temp(4)
        rConIter = 1 
        For i = 0 To 31
            result(i) = key(i)
        Next 
        For i = 32 To 239 Step 4
            temp(0) = result(i - 4)
            temp(1) = result(i - 3)
            temp(2) = result(i - 2)
            temp(3) = result(i - 1) 
            If i Mod 32 = 0 Then
                temp = keyScheduleCore(temp, rConIter, box, rcon)
                rConIter = rConIter + 1
            End If 
            If i Mod 32 = 16 Then
                temp(0) = box(temp(0))
                temp(1) = box(temp(1))
                temp(2) = box(temp(2))
                temp(3) = box(temp(3))
            End If 
            result(i) = result(i-32) Xor temp(0)
            result(i+1) = result(i-31) Xor temp(1)
            result(i+2) = result(i-30) Xor temp(2)
            result(i+3) = result(i-29) Xor temp(3)
        Next 
        exPandKey = result
    End Function
    这是密码块链接模式的代码。
    Sub RunAES(sFile)
        Dim sbox, sboxinv, rcon
        Dim g2, g3, g9, g11, g13, g14 
        g2 = Array( _
            &h00,&h02,&h04,&h06,&h08,&h0a,&h0c,&h0e,&h10,&h12,&h14,&h16,&h18,&h1a,&h1c,&h1e, _
            &h20,&h22,&h24,&h26,&h28,&h2a,&h2c,&h2e,&h30,&h32,&h34,&h36,&h38,&h3a,&h3c,&h3e, _
            &h40,&h42,&h44,&h46,&h48,&h4a,&h4c,&h4e,&h50,&h52,&h54,&h56,&h58,&h5a,&h5c,&h5e, _
            &h60,&h62,&h64,&h66,&h68,&h6a,&h6c,&h6e,&h70,&h72,&h74,&h76,&h78,&h7a,&h7c,&h7e, _
            &h80,&h82,&h84,&h86,&h88,&h8a,&h8c,&h8e,&h90,&h92,&h94,&h96,&h98,&h9a,&h9c,&h9e, _
            &ha0,&ha2,&ha4,&ha6,&ha8,&haa,&hac,&hae,&hb0,&hb2,&hb4,&hb6,&hb8,&hba,&hbc,&hbe, _
            &hc0,&hc2,&hc4,&hc6,&hc8,&hca,&hcc,&hce,&hd0,&hd2,&hd4,&hd6,&hd8,&hda,&hdc,&hde, _
            &he0,&he2,&he4,&he6,&he8,&hea,&hec,&hee,&hf0,&hf2,&hf4,&hf6,&hf8,&hfa,&hfc,&hfe, _
            &h1b,&h19,&h1f,&h1d,&h13,&h11,&h17,&h15,&h0b,&h09,&h0f,&h0d,&h03,&h01,&h07,&h05, _
            &h3b,&h39,&h3f,&h3d,&h33,&h31,&h37,&h35,&h2b,&h29,&h2f,&h2d,&h23,&h21,&h27,&h25, _
            &h5b,&h59,&h5f,&h5d,&h53,&h51,&h57,&h55,&h4b,&h49,&h4f,&h4d,&h43,&h41,&h47,&h45, _
            &h7b,&h79,&h7f,&h7d,&h73,&h71,&h77,&h75,&h6b,&h69,&h6f,&h6d,&h63,&h61,&h67,&h65, _
            &h9b,&h99,&h9f,&h9d,&h93,&h91,&h97,&h95,&h8b,&h89,&h8f,&h8d,&h83,&h81,&h87,&h85, _
            &hbb,&hb9,&hbf,&hbd,&hb3,&hb1,&hb7,&hb5,&hab,&ha9,&haf,&had,&ha3,&ha1,&ha7,&ha5, _
            &hdb,&hd9,&hdf,&hdd,&hd3,&hd1,&hd7,&hd5,&hcb,&hc9,&hcf,&hcd,&hc3,&hc1,&hc7,&hc5, _
            &hfb,&hf9,&hff,&hfd,&hf3,&hf1,&hf7,&hf5,&heb,&he9,&hef,&hed,&he3,&he1,&he7,&he5) 
        g3 = Array( _
            &h00,&h03,&h06,&h05,&h0c,&h0f,&h0a,&h09,&h18,&h1b,&h1e,&h1d,&h14,&h17,&h12,&h11, _
            &h30,&h33,&h36,&h35,&h3c,&h3f,&h3a,&h39,&h28,&h2b,&h2e,&h2d,&h24,&h27,&h22,&h21, _
            &h60,&h63,&h66,&h65,&h6c,&h6f,&h6a,&h69,&h78,&h7b,&h7e,&h7d,&h74,&h77,&h72,&h71, _
            &h50,&h53,&h56,&h55,&h5c,&h5f,&h5a,&h59,&h48,&h4b,&h4e,&h4d,&h44,&h47,&h42,&h41, _
            &hc0,&hc3,&hc6,&hc5,&hcc,&hcf,&hca,&hc9,&hd8,&hdb,&hde,&hdd,&hd4,&hd7,&hd2,&hd1, _
            &hf0,&hf3,&hf6,&hf5,&hfc,&hff,&hfa,&hf9,&he8,&heb,&hee,&hed,&he4,&he7,&he2,&he1, _
            &ha0,&ha3,&ha6,&ha5,&hac,&haf,&haa,&ha9,&hb8,&hbb,&hbe,&hbd,&hb4,&hb7,&hb2,&hb1, _
            &h90,&h93,&h96,&h95,&h9c,&h9f,&h9a,&h99,&h88,&h8b,&h8e,&h8d,&h84,&h87,&h82,&h81, _
            &h9b,&h98,&h9d,&h9e,&h97,&h94,&h91,&h92,&h83,&h80,&h85,&h86,&h8f,&h8c,&h89,&h8a, _
            &hab,&ha8,&had,&hae,&ha7,&ha4,&ha1,&ha2,&hb3,&hb0,&hb5,&hb6,&hbf,&hbc,&hb9,&hba, _
            &hfb,&hf8,&hfd,&hfe,&hf7,&hf4,&hf1,&hf2,&he3,&he0,&he5,&he6,&hef,&hec,&he9,&hea, _
            &hcb,&hc8,&hcd,&hce,&hc7,&hc4,&hc1,&hc2,&hd3,&hd0,&hd5,&hd6,&hdf,&hdc,&hd9,&hda, _
            &h5b,&h58,&h5d,&h5e,&h57,&h54,&h51,&h52,&h43,&h40,&h45,&h46,&h4f,&h4c,&h49,&h4a, _
            &h6b,&h68,&h6d,&h6e,&h67,&h64,&h61,&h62,&h73,&h70,&h75,&h76,&h7f,&h7c,&h79,&h7a, _
            &h3b,&h38,&h3d,&h3e,&h37,&h34,&h31,&h32,&h23,&h20,&h25,&h26,&h2f,&h2c,&h29,&h2a, _
            &h0b,&h08,&h0d,&h0e,&h07,&h04,&h01,&h02,&h13,&h10,&h15,&h16,&h1f,&h1c,&h19,&h1a) 
        g9 = Array( _
            &h00,&h09,&h12,&h1b,&h24,&h2d,&h36,&h3f,&h48,&h41,&h5a,&h53,&h6c,&h65,&h7e,&h77, _
            &h90,&h99,&h82,&h8b,&hb4,&hbd,&ha6,&haf,&hd8,&hd1,&hca,&hc3,&hfc,&hf5,&hee,&he7, _
            &h3b,&h32,&h29,&h20,&h1f,&h16,&h0d,&h04,&h73,&h7a,&h61,&h68,&h57,&h5e,&h45,&h4c, _
            &hab,&ha2,&hb9,&hb0,&h8f,&h86,&h9d,&h94,&he3,&hea,&hf1,&hf8,&hc7,&hce,&hd5,&hdc, _
            &h76,&h7f,&h64,&h6d,&h52,&h5b,&h40,&h49,&h3e,&h37,&h2c,&h25,&h1a,&h13,&h08,&h01, _
            &he6,&hef,&hf4,&hfd,&hc2,&hcb,&hd0,&hd9,&hae,&ha7,&hbc,&hb5,&h8a,&h83,&h98,&h91, _
            &h4d,&h44,&h5f,&h56,&h69,&h60,&h7b,&h72,&h05,&h0c,&h17,&h1e,&h21,&h28,&h33,&h3a, _
            &hdd,&hd4,&hcf,&hc6,&hf9,&hf0,&heb,&he2,&h95,&h9c,&h87,&h8e,&hb1,&hb8,&ha3,&haa, _
            &hec,&he5,&hfe,&hf7,&hc8,&hc1,&hda,&hd3,&ha4,&had,&hb6,&hbf,&h80,&h89,&h92,&h9b, _
            &h7c,&h75,&h6e,&h67,&h58,&h51,&h4a,&h43,&h34,&h3d,&h26,&h2f,&h10,&h19,&h02,&h0b, _
            &hd7,&hde,&hc5,&hcc,&hf3,&hfa,&he1,&he8,&h9f,&h96,&h8d,&h84,&hbb,&hb2,&ha9,&ha0, _
            &h47,&h4e,&h55,&h5c,&h63,&h6a,&h71,&h78,&h0f,&h06,&h1d,&h14,&h2b,&h22,&h39,&h30, _
            &h9a,&h93,&h88,&h81,&hbe,&hb7,&hac,&ha5,&hd2,&hdb,&hc0,&hc9,&hf6,&hff,&he4,&hed, _
            &h0a,&h03,&h18,&h11,&h2e,&h27,&h3c,&h35,&h42,&h4b,&h50,&h59,&h66,&h6f,&h74,&h7d, _
            &ha1,&ha8,&hb3,&hba,&h85,&h8c,&h97,&h9e,&he9,&he0,&hfb,&hf2,&hcd,&hc4,&hdf,&hd6, _
            &h31,&h38,&h23,&h2a,&h15,&h1c,&h07,&h0e,&h79,&h70,&h6b,&h62,&h5d,&h54,&h4f,&h46) 
        g11 = Array( _
            &h00,&h0b,&h16,&h1d,&h2c,&h27,&h3a,&h31,&h58,&h53,&h4e,&h45,&h74,&h7f,&h62,&h69, _
            &hb0,&hbb,&ha6,&had,&h9c,&h97,&h8a,&h81,&he8,&he3,&hfe,&hf5,&hc4,&hcf,&hd2,&hd9, _
            &h7b,&h70,&h6d,&h66,&h57,&h5c,&h41,&h4a,&h23,&h28,&h35,&h3e,&h0f,&h04,&h19,&h12, _
            &hcb,&hc0,&hdd,&hd6,&he7,&hec,&hf1,&hfa,&h93,&h98,&h85,&h8e,&hbf,&hb4,&ha9,&ha2, _
            &hf6,&hfd,&he0,&heb,&hda,&hd1,&hcc,&hc7,&hae,&ha5,&hb8,&hb3,&h82,&h89,&h94,&h9f, _
            &h46,&h4d,&h50,&h5b,&h6a,&h61,&h7c,&h77,&h1e,&h15,&h08,&h03,&h32,&h39,&h24,&h2f, _
            &h8d,&h86,&h9b,&h90,&ha1,&haa,&hb7,&hbc,&hd5,&hde,&hc3,&hc8,&hf9,&hf2,&hef,&he4, _
            &h3d,&h36,&h2b,&h20,&h11,&h1a,&h07,&h0c,&h65,&h6e,&h73,&h78,&h49,&h42,&h5f,&h54, _
            &hf7,&hfc,&he1,&hea,&hdb,&hd0,&hcd,&hc6,&haf,&ha4,&hb9,&hb2,&h83,&h88,&h95,&h9e, _
            &h47,&h4c,&h51,&h5a,&h6b,&h60,&h7d,&h76,&h1f,&h14,&h09,&h02,&h33,&h38,&h25,&h2e, _
            &h8c,&h87,&h9a,&h91,&ha0,&hab,&hb6,&hbd,&hd4,&hdf,&hc2,&hc9,&hf8,&hf3,&hee,&he5, _
            &h3c,&h37,&h2a,&h21,&h10,&h1b,&h06,&h0d,&h64,&h6f,&h72,&h79,&h48,&h43,&h5e,&h55, _
            &h01,&h0a,&h17,&h1c,&h2d,&h26,&h3b,&h30,&h59,&h52,&h4f,&h44,&h75,&h7e,&h63,&h68, _
            &hb1,&hba,&ha7,&hac,&h9d,&h96,&h8b,&h80,&he9,&he2,&hff,&hf4,&hc5,&hce,&hd3,&hd8, _
            &h7a,&h71,&h6c,&h67,&h56,&h5d,&h40,&h4b,&h22,&h29,&h34,&h3f,&h0e,&h05,&h18,&h13, _
            &hca,&hc1,&hdc,&hd7,&he6,&hed,&hf0,&hfb,&h92,&h99,&h84,&h8f,&hbe,&hb5,&ha8,&ha3) 
        g13 = Array( _
            &h00,&h0d,&h1a,&h17,&h34,&h39,&h2e,&h23,&h68,&h65,&h72,&h7f,&h5c,&h51,&h46,&h4b, _
            &hd0,&hdd,&hca,&hc7,&he4,&he9,&hfe,&hf3,&hb8,&hb5,&ha2,&haf,&h8c,&h81,&h96,&h9b, _
            &hbb,&hb6,&ha1,&hac,&h8f,&h82,&h95,&h98,&hd3,&hde,&hc9,&hc4,&he7,&hea,&hfd,&hf0, _
            &h6b,&h66,&h71,&h7c,&h5f,&h52,&h45,&h48,&h03,&h0e,&h19,&h14,&h37,&h3a,&h2d,&h20, _
            &h6d,&h60,&h77,&h7a,&h59,&h54,&h43,&h4e,&h05,&h08,&h1f,&h12,&h31,&h3c,&h2b,&h26, _
            &hbd,&hb0,&ha7,&haa,&h89,&h84,&h93,&h9e,&hd5,&hd8,&hcf,&hc2,&he1,&hec,&hfb,&hf6, _
            &hd6,&hdb,&hcc,&hc1,&he2,&hef,&hf8,&hf5,&hbe,&hb3,&ha4,&ha9,&h8a,&h87,&h90,&h9d, _
            &h06,&h0b,&h1c,&h11,&h32,&h3f,&h28,&h25,&h6e,&h63,&h74,&h79,&h5a,&h57,&h40,&h4d, _
            &hda,&hd7,&hc0,&hcd,&hee,&he3,&hf4,&hf9,&hb2,&hbf,&ha8,&ha5,&h86,&h8b,&h9c,&h91, _
            &h0a,&h07,&h10,&h1d,&h3e,&h33,&h24,&h29,&h62,&h6f,&h78,&h75,&h56,&h5b,&h4c,&h41, _
            &h61,&h6c,&h7b,&h76,&h55,&h58,&h4f,&h42,&h09,&h04,&h13,&h1e,&h3d,&h30,&h27,&h2a, _
            &hb1,&hbc,&hab,&ha6,&h85,&h88,&h9f,&h92,&hd9,&hd4,&hc3,&hce,&hed,&he0,&hf7,&hfa, _
            &hb7,&hba,&had,&ha0,&h83,&h8e,&h99,&h94,&hdf,&hd2,&hc5,&hc8,&heb,&he6,&hf1,&hfc, _
            &h67,&h6a,&h7d,&h70,&h53,&h5e,&h49,&h44,&h0f,&h02,&h15,&h18,&h3b,&h36,&h21,&h2c, _
            &h0c,&h01,&h16,&h1b,&h38,&h35,&h22,&h2f,&h64,&h69,&h7e,&h73,&h50,&h5d,&h4a,&h47, _
            &hdc,&hd1,&hc6,&hcb,&he8,&he5,&hf2,&hff,&hb4,&hb9,&hae,&ha3,&h80,&h8d,&h9a,&h97) 
        g14 = Array( _
            &h00,&h0e,&h1c,&h12,&h38,&h36,&h24,&h2a,&h70,&h7e,&h6c,&h62,&h48,&h46,&h54,&h5a, _
            &he0,&hee,&hfc,&hf2,&hd8,&hd6,&hc4,&hca,&h90,&h9e,&h8c,&h82,&ha8,&ha6,&hb4,&hba, _
            &hdb,&hd5,&hc7,&hc9,&he3,&hed,&hff,&hf1,&hab,&ha5,&hb7,&hb9,&h93,&h9d,&h8f,&h81, _
            &h3b,&h35,&h27,&h29,&h03,&h0d,&h1f,&h11,&h4b,&h45,&h57,&h59,&h73,&h7d,&h6f,&h61, _
            &had,&ha3,&hb1,&hbf,&h95,&h9b,&h89,&h87,&hdd,&hd3,&hc1,&hcf,&he5,&heb,&hf9,&hf7, _
            &h4d,&h43,&h51,&h5f,&h75,&h7b,&h69,&h67,&h3d,&h33,&h21,&h2f,&h05,&h0b,&h19,&h17, _
            &h76,&h78,&h6a,&h64,&h4e,&h40,&h52,&h5c,&h06,&h08,&h1a,&h14,&h3e,&h30,&h22,&h2c, _
            &h96,&h98,&h8a,&h84,&hae,&ha0,&hb2,&hbc,&he6,&he8,&hfa,&hf4,&hde,&hd0,&hc2,&hcc, _
            &h41,&h4f,&h5d,&h53,&h79,&h77,&h65,&h6b,&h31,&h3f,&h2d,&h23,&h09,&h07,&h15,&h1b, _
            &ha1,&haf,&hbd,&hb3,&h99,&h97,&h85,&h8b,&hd1,&hdf,&hcd,&hc3,&he9,&he7,&hf5,&hfb, _
            &h9a,&h94,&h86,&h88,&ha2,&hac,&hbe,&hb0,&hea,&he4,&hf6,&hf8,&hd2,&hdc,&hce,&hc0, _
            &h7a,&h74,&h66,&h68,&h42,&h4c,&h5e,&h50,&h0a,&h04,&h16,&h18,&h32,&h3c,&h2e,&h20, _
            &hec,&he2,&hf0,&hfe,&hd4,&hda,&hc8,&hc6,&h9c,&h92,&h80,&h8e,&ha4,&haa,&hb8,&hb6, _
            &h0c,&h02,&h10,&h1e,&h34,&h3a,&h28,&h26,&h7c,&h72,&h60,&h6e,&h44,&h4a,&h58,&h56, _
            &h37,&h39,&h2b,&h25,&h0f,&h01,&h13,&h1d,&h47,&h49,&h5b,&h55,&h7f,&h71,&h63,&h6d, _
            &hd7,&hd9,&hcb,&hc5,&hef,&he1,&hf3,&hfd,&ha7,&ha9,&hbb,&hb5,&h9f,&h91,&h83,&h8d) 
        sbox = Array( _
            &h63, &h7c, &h77, &h7b, &hf2, &h6b, &h6f, &hc5, &h30, &h01, &h67, &h2b, &hfe, &hd7, &hab, &h76, _
            &hca, &h82, &hc9, &h7d, &hfa, &h59, &h47, &hf0, &had, &hd4, &ha2, &haf, &h9c, &ha4, &h72, &hc0, _
            &hb7, &hfd, &h93, &h26, &h36, &h3f, &hf7, &hcc, &h34, &ha5, &he5, &hf1, &h71, &hd8, &h31, &h15, _
            &h04, &hc7, &h23, &hc3, &h18, &h96, &h05, &h9a, &h07, &h12, &h80, &he2, &heb, &h27, &hb2, &h75, _
            &h09, &h83, &h2c, &h1a, &h1b, &h6e, &h5a, &ha0, &h52, &h3b, &hd6, &hb3, &h29, &he3, &h2f, &h84, _
            &h53, &hd1, &h00, &hed, &h20, &hfc, &hb1, &h5b, &h6a, &hcb, &hbe, &h39, &h4a, &h4c, &h58, &hcf, _
            &hd0, &hef, &haa, &hfb, &h43, &h4d, &h33, &h85, &h45, &hf9, &h02, &h7f, &h50, &h3c, &h9f, &ha8, _
            &h51, &ha3, &h40, &h8f, &h92, &h9d, &h38, &hf5, &hbc, &hb6, &hda, &h21, &h10, &hff, &hf3, &hd2, _
            &hcd, &h0c, &h13, &hec, &h5f, &h97, &h44, &h17, &hc4, &ha7, &h7e, &h3d, &h64, &h5d, &h19, &h73, _
            &h60, &h81, &h4f, &hdc, &h22, &h2a, &h90, &h88, &h46, &hee, &hb8, &h14, &hde, &h5e, &h0b, &hdb, _
            &he0, &h32, &h3a, &h0a, &h49, &h06, &h24, &h5c, &hc2, &hd3, &hac, &h62, &h91, &h95, &he4, &h79, _
            &he7, &hc8, &h37, &h6d, &h8d, &hd5, &h4e, &ha9, &h6c, &h56, &hf4, &hea, &h65, &h7a, &hae, &h08, _
            &hba, &h78, &h25, &h2e, &h1c, &ha6, &hb4, &hc6, &he8, &hdd, &h74, &h1f, &h4b, &hbd, &h8b, &h8a, _
            &h70, &h3e, &hb5, &h66, &h48, &h03, &hf6, &h0e, &h61, &h35, &h57, &hb9, &h86, &hc1, &h1d, &h9e, _
            &he1, &hf8, &h98, &h11, &h69, &hd9, &h8e, &h94, &h9b, &h1e, &h87, &he9, &hce, &h55, &h28, &hdf, _
            &h8c, &ha1, &h89, &h0d, &hbf, &he6, &h42, &h68, &h41, &h99, &h2d, &h0f, &hb0, &h54, &hbb, &h16) 
        sboxinv = Array( _
            &h52, &h09, &h6a, &hd5, &h30, &h36, &ha5, &h38, &hbf, &h40, &ha3, &h9e, &h81, &hf3, &hd7, &hfb, _
            &h7c, &he3, &h39, &h82, &h9b, &h2f, &hff, &h87, &h34, &h8e, &h43, &h44, &hc4, &hde, &he9, &hcb, _
            &h54, &h7b, &h94, &h32, &ha6, &hc2, &h23, &h3d, &hee, &h4c, &h95, &h0b, &h42, &hfa, &hc3, &h4e, _
            &h08, &h2e, &ha1, &h66, &h28, &hd9, &h24, &hb2, &h76, &h5b, &ha2, &h49, &h6d, &h8b, &hd1, &h25, _
            &h72, &hf8, &hf6, &h64, &h86, &h68, &h98, &h16, &hd4, &ha4, &h5c, &hcc, &h5d, &h65, &hb6, &h92, _
            &h6c, &h70, &h48, &h50, &hfd, &hed, &hb9, &hda, &h5e, &h15, &h46, &h57, &ha7, &h8d, &h9d, &h84, _
            &h90, &hd8, &hab, &h00, &h8c, &hbc, &hd3, &h0a, &hf7, &he4, &h58, &h05, &hb8, &hb3, &h45, &h06, _
            &hd0, &h2c, &h1e, &h8f, &hca, &h3f, &h0f, &h02, &hc1, &haf, &hbd, &h03, &h01, &h13, &h8a, &h6b, _
            &h3a, &h91, &h11, &h41, &h4f, &h67, &hdc, &hea, &h97, &hf2, &hcf, &hce, &hf0, &hb4, &he6, &h73, _
            &h96, &hac, &h74, &h22, &he7, &had, &h35, &h85, &he2, &hf9, &h37, &he8, &h1c, &h75, &hdf, &h6e, _
            &h47, &hf1, &h1a, &h71, &h1d, &h29, &hc5, &h89, &h6f, &hb7, &h62, &h0e, &haa, &h18, &hbe, &h1b, _
            &hfc, &h56, &h3e, &h4b, &hc6, &hd2, &h79, &h20, &h9a, &hdb, &hc0, &hfe, &h78, &hcd, &h5a, &hf4, _
            &h1f, &hdd, &ha8, &h33, &h88, &h07, &hc7, &h31, &hb1, &h12, &h10, &h59, &h27, &h80, &hec, &h5f, _
            &h60, &h51, &h7f, &ha9, &h19, &hb5, &h4a, &h0d, &h2d, &he5, &h7a, &h9f, &h93, &hc9, &h9c, &hef, _
            &ha0, &he0, &h3b, &h4d, &hae, &h2a, &hf5, &hb0, &hc8, &heb, &hbb, &h3c, &h83, &h53, &h99, &h61, _
            &h17, &h2b, &h04, &h7e, &hba, &h77, &hd6, &h26, &he1, &h69, &h14, &h63, &h55, &h21, &h0c, &h7d) 
        rcon = Array( _
            &h8d, &h01, &h02, &h04, &h08, &h10, &h20, &h40, &h80, &h1b, &h36, &h6c, &hd8, &hab, &h4d, &h9a, _
            &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, &h6a, &hd4, &hb3, &h7d, &hfa, &hef, &hc5, &h91, &h39, _
            &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, &h25, &h4a, &h94, &h33, &h66, &hcc, &h83, &h1d, &h3a, _
            &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, &h08, &h10, &h20, &h40, &h80, &h1b, &h36, &h6c, &hd8, _
            &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, &h6a, &hd4, &hb3, &h7d, &hfa, &hef, _
            &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, &h25, &h4a, &h94, &h33, &h66, &hcc, _
            &h83, &h1d, &h3a, &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, &h08, &h10, &h20, &h40, &h80, &h1b, _
            &h36, &h6c, &hd8, &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, &h6a, &hd4, &hb3, _
            &h7d, &hfa, &hef, &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, &h25, &h4a, &h94, _
            &h33, &h66, &hcc, &h83, &h1d, &h3a, &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, &h08, &h10, &h20, _
            &h40, &h80, &h1b, &h36, &h6c, &hd8, &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, &hc6, &h97, &h35, _
            &h6a, &hd4, &hb3, &h7d, &hfa, &hef, &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, &h61, &hc2, &h9f, _
            &h25, &h4a, &h94, &h33, &h66, &hcc, &h83, &h1d, &h3a, &h74, &he8, &hcb, &h8d, &h01, &h02, &h04, _
            &h08, &h10, &h20, &h40, &h80, &h1b, &h36, &h6c, &hd8, &hab, &h4d, &h9a, &h2f, &h5e, &hbc, &h63, _
            &hc6, &h97, &h35, &h6a, &hd4, &hb3, &h7d, &hfa, &hef, &hc5, &h91, &h39, &h72, &he4, &hd3, &hbd, _
            &h61, &hc2, &h9f, &h25, &h4a, &h94, &h33, &h66, &hcc, &h83, &h1d, &h3a, &h74, &he8, &hcb) 
        Dim expandedKey, block(16), aesKey(32), i, isDone, j, isEncode
        Dim sPlain, sPass, sCipher, sTemp, nonce(16), priorCipher(16)
        Dim oFile1, oFS, oFile2
        Dim x, r, y, temp(4), intTemp 
        Set oFS = CreateObject("Scripting.FileSystemObject")
        Set oFile1 = oFS.OpenTextFile(sFile, ForReading) 
        If Right(sFile, 4) <> ".enc" Then
            sFile = sFile & ".enc"
            oFS.CreateTextFile sFile, 2, True
            isEncode = True
        Else
            sFile = Left(sFile, Len(sFile) - 4) & ".unenc"
            oFS.CreateTextFile sFile, 2, True
            isEncode = False
        End If 
        Set oFile2 = oFS.OpenTextFile(sFile, ForWriting)
        Set oFS = Nothing 
        For i = 0 To 15
            nonce(i) = 0
        Next 
        For i = 0 To (Len(oPW.Value) - 1)
            aesKey(i) = Asc(Mid(oPW.Value, i + 1, 1))
        Next 
        For i = Len(oPW.Value) To 31
            aesKey(i) = 0
        Next 
        expandedKey = expandKey(aesKey, sbox, rcon) 
        Do Until oFile1.AtEndOfStream
            sPlain = oFile1.Read(1024)
            sCipher = ""
            j = 0
            isDone = False 
            Do Until isDone
                sTemp = Mid(sPlain, j*16 + 1, 16) 
                If Len(sTemp) < 16 Then
                    For i = Len(sTemp) To 15
                        sTemp = sTemp & Chr(0)
                    Next
                End If 
                For i = 0 To 15
                    block(i) = Asc(Mid(sTemp, (i Mod 4) * 4 + (i \ 4) + 1, 1))
                Next 
                If (j + 1) * 16 >= Len(sPlain) Then
                    isDone = True
                End If 
                j = j + 1 
                If isEncode Then
                    r= 0
                    For i = 0 To 15
                        block(i) = block(i) Xor nonce(i) Xor expandedKey((i Mod 4) * 4 + (i \ 4))
                    Next 
                    For x = 1 To 13
                        block(0) = sbox(block(0))
                        block(1) = sbox(block(1))
                        block(2) = sbox(block(2))
                        block(3) = sbox(block(3)) 
                        intTemp = sbox(block(4))
                        block(4) = sbox(block(5))
                        block(5) = sbox(block(6))
                        block(6) = sbox(block(7))
                        block(7) = intTemp 
                        intTemp = sbox(block(8))
                        block(8) = sbox(block(10))
                        block(10) = intTemp
                        intTemp = sbox(block(9))
                        block(9) = sbox(block(11))
                        block(11) = intTemp 
                        intTemp = sbox(block(12))
                        block(12) = sbox(block(15))
                        block(15) = sbox(block(14))
                        block(14) = sbox(block(13))
                        block(13) = intTemp 
                        r = x * 16
                        For i = 0 To 3
                            temp(0) = block(i)
                            temp(1) = block(i+4)
                            temp(2) = block(i+8)
                            temp(3) = block(i+12) 
                            block(i) = g2(temp(0)) Xor temp(3) Xor temp(2) Xor g3(temp(1)) Xor expandedKey(r+i*4)
                            block(i+4) = g2(temp(1)) Xor temp(0) Xor temp(3) Xor g3(temp(2)) Xor expandedKey(r+i*4+1)
                            block(i+8) = g2(temp(2)) Xor temp(1) Xor temp(0) Xor g3(temp(3)) Xor expandedKey(r+i*4+2)
                            block(i+12) = g2(temp(3)) Xor temp(2) Xor temp(1) Xor g3(temp(0)) Xor expandedKey(r+i*4+3)
                        Next
                    Next 
                    block(0) = sbox(block(0)) Xor expandedKey(224)
                    block(1) = sbox(block(1)) Xor expandedKey(228)
                    block(2) = sbox(block(2)) Xor expandedKey(232)
                    block(3) = sbox(block(3)) Xor expandedKey(236) 
                    intTemp = sbox(block(4)) Xor expandedKey(237)
                    block(4) = sbox(block(5)) Xor expandedKey(225)
                    block(5) = sbox(block(6)) Xor expandedKey(229)
                    block(6) = sbox(block(7)) Xor expandedKey(233)
                    block(7) = intTemp 
                    intTemp = sbox(block(8)) Xor expandedKey(234)
                    block(8) = sbox(block(10)) Xor expandedKey(226)
                    block(10) = intTemp
                    intTemp = sbox(block(9)) Xor expandedKey(238)
                    block(9) = sbox(block(11)) Xor expandedKey(230)
                    block(11) = intTemp 
                    intTemp = sbox(block(12)) Xor expandedKey(231)
                    block(12) = sbox(block(15)) Xor expandedKey(227)
                    block(15) = sbox(block(14)) Xor expandedKey(239)
                    block(14) = sbox(block(13)) Xor expandedKey(235)
                    block(13) = intTemp 
                    For i = 0 To 15
                        nonce(i) = block(i)
                    Next
                Else
                    For i = 0 To 15
                        priorCipher(i) = block(i)
                    Next 
                    block(0) = sboxinv(block(0) Xor expandedKey(224))
                    block(1) = sboxinv(block(1) Xor expandedKey(228))
                    block(2) = sboxinv(block(2) Xor expandedKey(232))
                    block(3) = sboxinv(block(3) Xor expandedKey(236)) 
                    intTemp = sboxinv(block(4) Xor expandedKey(225))
                    block(4) = sboxinv(block(7) Xor expandedKey(237))
                    block(7) = sboxinv(block(6) Xor expandedKey(233))
                    block(6) = sboxinv(block(5) Xor expandedKey(229))
                    block(5) = intTemp 
                    intTemp = sboxinv(block(8) Xor expandedKey(226))
                    block(8) = sboxinv(block(10) Xor expandedKey(234))
                    block(10) = intTemp
                    intTemp = sboxinv(block(9) Xor expandedKey(230))
                    block(9) = sboxinv(block(11) Xor expandedKey(238))
                    block(11) = intTemp 
                    intTemp = sboxinv(block(12) Xor expandedKey(227))
                    block(12) = sboxinv(block(13) Xor expandedKey(231))
                    block(13) = sboxinv(block(14) Xor expandedKey(235))
                    block(14) = sboxinv(block(15) Xor expandedKey(239))
                    block(15) = intTemp 
                    For x = 13 To 1 Step -1
                        r = x * 16 
                        For i = 0 To 3
                            temp(0) = block(i) Xor expandedKey(r+i*4)
                            temp(1) = block(i+4) Xor expandedKey(r+i*4+1)
                            temp(2) = block(i+8) Xor expandedKey(r+i*4+2)
                            temp(3) = block(i+12) Xor expandedKey(r+i*4+3) 
                            block(i) = g14(temp(0)) Xor g9(temp(3)) Xor g13(temp(2)) Xor g11(temp(1))
                            block(i+4) = g14(temp(1)) Xor g9(temp(0)) Xor g13(temp(3)) Xor g11(temp(2))
                            block(i+8) = g14(temp(2)) Xor g9(temp(1)) Xor g13(temp(0)) Xor g11(temp(3))
                            block(i+12) = g14(temp(3)) Xor g9(temp(2)) Xor g13(temp(1)) Xor g11(temp(0))
                        Next 
                        block(0) = sboxinv(block(0))
                        block(1) = sboxinv(block(1))
                        block(2) = sboxinv(block(2))
                        block(3) = sboxinv(block(3)) 
                        intTemp = sboxinv(block(4))
                        block(4) = sboxinv(block(7))
                        block(7) = sboxinv(block(6))
                        block(6) = sboxinv(block(5))
                        block(5) = intTemp 
                        intTemp = sboxinv(block(8))
                        block(8) = sboxinv(block(10))
                        block(10) = intTemp
                        intTemp = sboxinv(block(9))
                        block(9) = sboxinv(block(11))
                        block(11) = intTemp 
                        intTemp = sboxinv(block(12))
                        block(12) = sboxinv(block(13))
                        block(13) = sboxinv(block(14))
                        block(14) = sboxinv(block(15))
                        block(15) = intTemp
                    Next 
                    r= 0
                    For i = 0 To 15
                        block(i) = block(i) Xor expandedKey((i Mod 4) * 4 + (i \ 4)) Xor nonce(i)
                        nonce(i) = priorCipher(i)
                    Next
                End If 
                For i = 0 To 15
                    sCipher = sCipher & Chr(block((i Mod 4) * 4 + (i \ 4)))
                Next
            Loop 
            oFile2.Write sCipher
        Loop 
        oFile1.Close
        Set oFile1 = Nothing
        oFile2.Close
        Set oFile2 = Nothing
    End Sub

    From: https://bytes.com/topic/access/insights/906850-aes-encryption-algorithm-vba-vbscript

    展开全文
    cxygs5788 2020-05-25 12:40:52
  • 31KB weixin_39840588 2019-07-10 11:57:01
  • 4星
    50.45MB weixin_40292092 2019-02-15 08:23:35
  • 原因在于:1.Java中AES加密与解密默认使用AES/ECB/PKCS5Padding模式...2.php中的AES算法实现使用AES/ECB/NoPadding所以,把php的aes加密算法的补码方式采用PKCS5Padding 模式即可。附上可用的php和java 加解密互通的...

    1.php和java的aes默认加密算法有点区别,php能解密java加密的密文,但java不能解密php加密的密文。原因在于:

    1.Java中AES加密与解密默认使用AES/ECB/PKCS5Padding模式;

    2.php中的AES算法实现使用AES/ECB/NoPadding

    所以,把php的aes加密算法的补码方式采用 PKCS5Padding 模式即可。

    附上可用的php和java 加解密互通的算法类。

    class CryptAES

    {

    protected $cipher = MCRYPT_RIJNDAEL_128;

    protected $mode = MCRYPT_MODE_ECB;

    protected $pad_method = NULL;

    protected $secret_key = '';

    protected $iv = '';

    public function set_cipher($cipher)

    {

    $this->cipher = $cipher;

    }

    public function set_mode($mode)

    {

    $this->mode = $mode;

    }

    public function set_iv($iv)

    {

    $this->iv = $iv;

    }

    public function set_key($key)

    {

    $this->secret_key = $key;

    }

    public function require_pkcs5()

    {

    $this->pad_method = 'pkcs5';

    }

    protected function pad_or_unpad($str, $ext)

    {

    if ( is_null($this->pad_method) )

    {

    return $str;

    }

    else

    {

    $func_name = __CLASS__ . '::' . $this->pad_method . '_' . $ext . 'pad';

    if ( is_callable($func_name) )

    {

    $size = mcrypt_get_block_size($this->cipher, $this->mode);

    return call_user_func($func_name, $str, $size);

    }

    }

    return $str;

    }

    protected function pad($str)

    {

    return $this->pad_or_unpad($str, '');

    }

    protected function unpad($str)

    {

    return $this->pad_or_unpad($str, 'un');

    }

    public function encrypt($str)

    {

    $str = $this->pad($str);

    $td = mcrypt_module_open($this->cipher, '', $this->mode, '');

    if ( empty($this->iv) )

    {

    $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

    }

    else

    {

    $iv = $this->iv;

    }

    mcrypt_generic_init($td, $this->secret_key, $iv);

    $cyper_text = mcrypt_generic($td, $str);

    $rt=base64_encode($cyper_text);

    //$rt = bin2hex($cyper_text);

    mcrypt_generic_deinit($td);

    mcrypt_module_close($td);

    return $rt;

    }

    public function decrypt($str){

    $td = mcrypt_module_open($this->cipher, '', $this->mode, '');

    if ( empty($this->iv) )

    {

    $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND);

    }

    else

    {

    $iv = $this->iv;

    }

    mcrypt_generic_init($td, $this->secret_key, $iv);

    //$decrypted_text = mdecrypt_generic($td, self::hex2bin($str));

    $decrypted_text = mdecrypt_generic($td, base64_decode($str));

    $rt = $decrypted_text;

    mcrypt_generic_deinit($td);

    mcrypt_module_close($td);

    return $this->unpad($rt);

    }

    public static function hex2bin($hexdata) {

    $bindata = '';

    $length = strlen($hexdata);

    for ($i=0; $i < $length; $i += 2)

    {

    $bindata .= chr(hexdec(substr($hexdata, $i, 2)));

    }

    return $bindata;

    }

    public static function pkcs5_pad($text, $blocksize)

    {

    $pad = $blocksize - (strlen($text) % $blocksize);

    return $text . str_repeat(chr($pad), $pad);

    }

    public static function pkcs5_unpad($text)

    {

    $pad = ord($text{strlen($text) - 1});

    if ($pad > strlen($text)) return false;

    if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false;

    return substr($text, 0, -1 * $pad);

    }

    }

    $keyStr = '1345679';

    $plainText = 'a1e470e3bcc2953626cd6341fea4bd68';

    $aes = new CryptAES();

    $aes->set_key($keyStr);

    $aes->require_pkcs5();

    $encText = $aes->encrypt($plainText);

    $decString = $aes->decrypt('$encText');

    展开全文
    weixin_42499800 2021-02-12 15:20:06
  • 4星
    30KB jthkl 2012-07-19 14:44:41
  • 1.27MB twty_jinyuan2010 2011-09-09 04:10:20
  • 40KB qq_42007217 2020-07-18 10:13:10
  • 29KB weixin_38730331 2021-04-05 02:15:23
  • 3星
    35KB dejin 2009-03-19 12:08:31
  • 205KB ticols 2008-11-10 20:46:22
  • 5星
    48KB wstar 2013-12-19 14:15:51
  • 26KB swimming_sqp 2019-12-26 17:16:54
  • 2KB qq_21369525 2018-04-21 17:07:29
  • 203KB weixin_42166783 2018-11-01 14:20:56
  • 各有各的特点,前两者开发难度低,不过不同Excel版本间的兼容性差,使用宏开发,难度比较大,用的都是古老的vb,不过兼容性还是很好的。这里,使用了宏进行开发,同时还用到了C#。原理是这样的,使用宏,发送http...

    Excel的开发,方式多种多样,常见的有 开发Excel的加载项,Excel的外接程序,宏。各有各的特点,前两者开发难度低,不过不同Excel版本间的兼容性差,使用宏开发,难度比较大,用的都是古老的vb,不过兼容性还是很好的。

    这里,使用了宏进行开发,同时还用到了C#。原理是这样的,使用宏,发送http请求到C#开发的本地http服务器,处理完毕后将结果返回。

    演示的示例是,将第一列的明文,用第二列的密码加密,加密后保存在第三列。http url编码使用utf-8编码,返回Base64的加密结果

    Public Function UrlEncode(ByRef szString As String) As String
          Dim szChar   As String
          Dim szTemp   As String
          Dim szCode   As String
          Dim szHex    As String
          Dim szBin    As String
          Dim iCount1  As Integer
          Dim iCount2  As Integer
          Dim iStrLen1 As Integer
          Dim iStrLen2 As Integer
          Dim lResult  As Long
          Dim lAscVal  As Long
          szString = Trim$(szString)
          iStrLen1 = Len(szString)
          For iCount1 = 1 To iStrLen1
          szChar = Mid$(szString, iCount1, 1)
          lAscVal = AscW(szChar)
          If lAscVal >= &H0 And lAscVal <= &HFF Then
          If (lAscVal >= &H30 And lAscVal <= &H39) Or _
          (lAscVal >= &H41 And lAscVal <= &H5A) Or _
          (lAscVal >= &H61 And lAscVal <= &H7A) Then
          szCode = szCode & szChar
          Else
          szCode = szCode & "%" & Hex(AscW(szChar))
          End If
          Else
          szHex = Hex(AscW(szChar))
          iStrLen2 = Len(szHex)
          For iCount2 = 1 To iStrLen2
          szChar = Mid$(szHex, iCount2, 1)
          Select Case szChar
          Case Is = "0"
          szBin = szBin & "0000"
          Case Is = "1"
          szBin = szBin & "0001"
          Case Is = "2"
          szBin = szBin & "0010"
          Case Is = "3"
          szBin = szBin & "0011"
          Case Is = "4"
          szBin = szBin & "0100"
          Case Is = "5"
          szBin = szBin & "0101"
          Case Is = "6"
          szBin = szBin & "0110"
          Case Is = "7"
          szBin = szBin & "0111"
          Case Is = "8"
          szBin = szBin & "1000"
          Case Is = "9"
          szBin = szBin & "1001"
          Case Is = "A"
          szBin = szBin & "1010"
          Case Is = "B"
          szBin = szBin & "1011"
          Case Is = "C"
          szBin = szBin & "1100"
          Case Is = "D"
          szBin = szBin & "1101"
          Case Is = "E"
          szBin = szBin & "1110"
          Case Is = "F"
          szBin = szBin & "1111"
          Case Else
          End Select
          Next iCount2
          szTemp = "1110" & Left$(szBin, 4) & "10" & Mid$(szBin, 5, 6) & "10" & Right$(szBin, 6)
          For iCount2 = 1 To 24
          If Mid$(szTemp, iCount2, 1) = "1" Then
          lResult = lResult + 1 * 2 ^ (24 - iCount2)
          Else: lResult = lResult + 0 * 2 ^ (24 - iCount2)
          End If
          Next iCount2
          szTemp = Hex(lResult)
          szCode = szCode & "%" & Left$(szTemp, 2) & "%" & Mid$(szTemp, 3, 2) & "%" & Right$(szTemp, 2)
          End If
          szBin = vbNullString
          lResult = 0
          Next iCount1
          UrlEncode = szCode
          End Function
    
    Public Function http(msg As String, password As String) As String
        Dim Url As String
        Url = "http://127.0.0.1:8080/AES?msg=" & UrlEncode(msg) & "&password=" & UrlEncode(password)
     
        Dim objHttp As Object
        Set objHttp = CreateObject("msxml2.xmlhttp")
     
        objHttp.Open "GET", Url, 0
        objHttp.send
         
        While objHttp.readystate <> 4
            DoEvents
        Wend
        http = objHttp.responsetext
    End Function
    
    
    
    Sub AES加密()
    Dim i As Integer
    i = 1
    Do While Not IsEmpty(Cells(i, 1))
    
        If Not IsEmpty(Cells(i, 2)) Then
     
             Cells(i, 3) = http(Cells(i, 1), Cells(i, 2))
        
        End If
         i = i + 1
     Loop
    End Sub
    

    加密后,结果如上表格所示,这里的加密方式,是参照CryptoJS进行的,之所以选择这种方式,在于AES在线加密解密,均采用此标准,需要解密的时候,可以快速得找到解密的工具,例如:http://tool.oschina.net/encrypt。CryptoJS怎样加解密的,可以查看本博客的其他文章。

    利用http请求,再加上简单的宏,就可以处理很多的复杂事情。比如生成二维码,各种各样的加密解密,同时又保证与Excel各版本的兼容性,甚至可以在xp和excel2003上使用。

    代码:https://download.csdn.net/download/liangjintang/10364499

    展开全文
    liangjintang 2018-04-21 00:18:11
  • 401KB wangqiang036 2020-06-18 19:25:29
  • 12KB libra720 2011-08-11 23:08:59

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 509
精华内容 203
热门标签
关键字:

aes加密算法vb