MCPcopy Index your code
hub / github.com/f0ng/autoDecoder / encryptKeyivmode

Method encryptKeyivmode

src/com/autoDecoder/util/codeEncode.java:127–334  ·  view source on GitHub ↗
(String encryptedData,String sessionKey,String iv,String encodemode, String ivmode , String paddingmode ,String sSrcmode ,String keyivmode)

Source from the content-addressed store, hash-verified

125
126
127 public static String encryptKeyivmode(String encryptedData,String sessionKey,String iv,String encodemode, String ivmode , String paddingmode ,String sSrcmode ,String keyivmode) throws Exception {
128 encryptedData = encryptedData.trim();
129
130 Boolean zero = false;
131 if (paddingmode.equals("ZeroPadding")) {
132 paddingmode = "NoPadding";
133 zero = true;
134 }
135
136 if ( ivmode.equals("ECB") )
137 iv = "";
138
139// BurpExtender.stdout.println(encodemode);
140 if (encodemode.equals("null"))
141 return encryptedData;
142 else if (encodemode.equals("RSA")){
143 try {
144
145 if (IndexautoDecoder.getRadioButton12State())
146 return URLEncoder.encode(encrypt(encryptedData, sessionKey), "utf-8");
147 else
148 return encrypt(encryptedData, sessionKey);
149 }catch (Exception e){
150 BurpExtender.stdout.println(Arrays.toString(e.getStackTrace()));
151 return "RSA加密错误";
152 }
153 } else if ( encodemode.equals("SM4") ){ // SM4加密
154// BurpExtender.stdout.println(encryptedData);
155// BurpExtender.stdout.println(sessionKey);
156// BurpExtender.stdout.println(iv);
157// BurpExtender.stdout.println(encodemode);
158// BurpExtender.stdout.println(ivmode);
159// BurpExtender.stdout.println(paddingmode);
160// BurpExtender.stdout.println(sSrcmode);
161// BurpExtender.stdout.println(keyivmode);
162 byte[] data = null;
163 byte[] aseKey;
164 byte[] ivData;
165
166 if (keyivmode.equals("Base64")) {
167 aseKey = Base64.decodeBase64(sessionKey);
168 ivData = Base64.decodeBase64(iv);
169 } else if (keyivmode.equals("Hex")) {
170 aseKey = hexToByteArray(sessionKey);
171 ivData = hexToByteArray(iv);
172 } else {
173 aseKey = sessionKey.getBytes(StandardCharsets.UTF_8);
174 ivData = iv.getBytes(StandardCharsets.UTF_8);
175 }
176
177 if ( ivmode.equals("ECB") ) {
178
179 String s = Util.byteToHex(encryptedData.getBytes());
180// System.out.println("原文" + s);
181 SM4Utils sm42 = new SM4Utils();
182 //sm4.secretKey = "JeF8U9wHFOMfs2Y8";
183 sm42.secretKey = Util.byteToHex(aseKey);
184 sm42.hexString = true;

Callers 4

mainMethod · 0.95
EncodeMethod · 0.80
actionPerformedMethod · 0.80
processHttpMessageMethod · 0.80

Calls 10

getRadioButton12StateMethod · 0.95
byteToHexMethod · 0.95
encryptData_ECBMethod · 0.95
hexStringToByteArrayMethod · 0.95
encryptData_CBCMethod · 0.95
formatWithZeroPaddingMethod · 0.95
bytesToHexMethod · 0.95
encodeMethod · 0.80
hexToByteArrayMethod · 0.80
encryptMethod · 0.45

Tested by

no test coverage detected