Antiloveg vor 8 Jahren
Ursprung
Commit
18a549c922

+ 24 - 5
src/main/java/com/goafanti/admin/controller/AdminTechProjectController.java

@@ -29,6 +29,7 @@ import com.goafanti.common.model.TechProject;
 import com.goafanti.common.model.TechProjectLog;
 import com.goafanti.common.model.TechWebsite;
 import com.goafanti.common.model.User;
+import com.goafanti.common.utils.AesUtils;
 import com.goafanti.common.utils.Base64Utils;
 import com.goafanti.common.utils.FileUtils;
 import com.goafanti.common.utils.LoggerUtils;
@@ -281,7 +282,11 @@ public class AdminTechProjectController extends CertifyApiController {
 			List<TechWebsiteListBo> l = (List<TechWebsiteListBo>) t.getList();
 			for (TechWebsiteListBo w : l) {
 				if (!StringUtils.isBlank(w.getPassword())) {
-					w.setPassword(Base64Utils.decodeData(w.getPassword()));
+					try {
+						w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
+					} catch (Exception e) {
+					}
+					//w.setPassword(Base64Utils.decodeData(w.getPassword()));
 				}
 			}
 			t.setList(l);
@@ -297,7 +302,7 @@ public class AdminTechProjectController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/techWebsiteDetail", method = RequestMethod.POST)
-	public Result techWebsiteDetail(String id) {
+	public Result techWebsiteDetail(String id)  {
 		Result res = new Result();
 		if (!checkAdminLogin(res)) {
 			return res;
@@ -307,8 +312,15 @@ public class AdminTechProjectController extends CertifyApiController {
 		} else {
 			TechWebsiteDetailBo w = techWebsiteService.selectTechWebsiteDetail(id);
 			if (null != w && !StringUtils.isBlank(w.getPassword())) {
-				w.setPassword(Base64Utils.decodeData(w.getPassword()));
+				try {
+					w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
+				} catch (Exception e) {
+				}
 			}
+			
+			/*if (null != w && !StringUtils.isBlank(w.getPassword())) {
+				w.setPassword(Base64Utils.decodeData(w.getPassword()));
+			}*/
 				res.setData(w);
 		}
 		return res;
@@ -321,7 +333,7 @@ public class AdminTechProjectController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/disposeTechWebsite", method = RequestMethod.POST)
-	public Result disposeTechWebsite(@Valid InputTechWebsite w, BindingResult bindingResult) {
+	public Result disposeTechWebsite(@Valid InputTechWebsite w, BindingResult bindingResult)  {
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
 			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
@@ -342,8 +354,15 @@ public class AdminTechProjectController extends CertifyApiController {
 			return res;
 		}
 		
-		if (null != w && null != (w.getPassword())) {
+		/*if (null != w && null != (w.getPassword())) {
 			w.setPassword(Base64Utils.encodeData(w.getPassword().trim()));
+		}*/
+		
+		if (null != w && null != (w.getPassword())) {
+			try {
+				w.setPassword(AesUtils.encrypt(w.getPassword().trim(), aesSecretKey));
+			} catch (Exception e) {
+			}
 		}
 		
 		TechWebsite tw = new TechWebsite();

+ 3 - 2
src/main/java/com/goafanti/common/utils/AesUtils.java

@@ -30,7 +30,7 @@ public class AesUtils {
 
 			cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
 			byte[] encrypted = cipher.doFinal(plaintext);
-
+			System.out.println(ArrayUtils.toString(encrypted));
 			return Base64.encodeBase64String(encrypted);
 
 		} catch (Exception e) {
@@ -45,7 +45,7 @@ public class AesUtils {
 			String iv = key;
 
 			byte[] decoded = Base64.decodeBase64(data);
-
+System.out.println(ArrayUtils.toString(decoded));
 			Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
 			SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
 			IvParameterSpec ivspec = new IvParameterSpec(iv.getBytes());
@@ -68,6 +68,7 @@ public class AesUtils {
 		System.out.println(encrypted);
 		System.out.println(encrypted.length());
 		System.out.println(AesUtils.decrypt(encrypted, pwd));
+
 	}
 
 }

+ 1 - 1
src/main/resources/props/config_dev.properties

@@ -61,4 +61,4 @@ accessSecret=ICGuiUnqzaar7urw4zecVcJrJ1MHg9
 
 avatar.host=//afts.hnzhiming.com
 
-aesSecretKey=aft666
+aesSecretKey=aft1234567890123

+ 1 - 1
src/main/resources/props/config_local.properties

@@ -63,4 +63,4 @@ accessSecret=ICGuiUnqzaar7urw4zecVcJrJ1MHg9
 
 avatar.host=//afts.hnzhiming.com
 
-aesSecretKey=aft666
+aesSecretKey=aft1234567890123

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -63,4 +63,4 @@ accessSecret=ICGuiUnqzaar7urw4zecVcJrJ1MHg9
 
 avatar.host=//aftts.hnzhiming.com
 
-aesSecretKey = aft666
+aesSecretKey =aft1234567890123