文件名称:应用密码学des
文件大小:19KB
文件格式:CPP
更新时间:2017-01-08 14:19:14
des 密码
是c++实现的,des算法: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