From f0b471db37998c385f20dfc95f2714d1083b6f8c Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Thu, 8 Jun 2023 12:03:24 +0800 Subject: [PATCH] password entity Signed-off-by: Chenx221 --- .../classes/cyou/chenx221/pojo/Password.class | Bin 0 -> 1623 bytes .../java/cyou/chenx221/pojo/Password.java | 36 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Password.class create mode 100644 project2/src/main/java/cyou/chenx221/pojo/Password.java diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Password.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/pojo/Password.class new file mode 100644 index 0000000000000000000000000000000000000000..1fb6897cd11d2348b9886c6a62ac05f48b7f7131 GIT binary patch literal 1623 zcmaJ>-%}b_6#gzOEa0L@#7InD;(#oBD3{yzym^N?`Geqgf>`1HIw!NcVMRq!7UEa6rvcvqw>e4GY9nW+uDX{!* zgy%b0i{TPxbzC-Z1@E0=u%Dnngb|8Ip6m!{ne1Ls!F%7pHGDvJYXcbJ%wCZ)9oGde zzD-iGYd34M9m5=gF?@uKj;w(NERvs*ZpravUACE$=WffxVfa+0bPmS~_L6~{$Pq+S zI(4t%m$;;YEE`zCDg|b%B^{RXa%S_aj{zz&Fo!$JA}_G?ZvOnP>VtaI@)HA}qCl2B zcZhf@b2iu-HCiXFrER)3R%@bcJ94M{Y+ts&Husx6NtRv9Z0?$ETm26XHLqcl{43@E zX;=DBorir_AhvaA$(CokPDjUmf%((@wBuI0R%4@CciCQzXD7;}vmp-!#6I7m3V+(} zR39?D)-XG)L12%%QCbe!NT2EUA$6Lq&cv#2w{6J> zwqhwhyh}F~Bz9tiV*q>uSVO}9;^pJ6L8!sNb)A2!+y(d0!gGk)eKRq#-VVJ zUq)XEpW$=F=5R2Snl$goM7r0Ql!4T;luI~Jexo@B2!-BR{2&F?W^Wk7#PwA=fFSwl! zrS#Q&WD>`z$d4~DUx=ooJ>1ZK##mZQ-0I=h)3m0JZa@7=7r!3=lh%6p_%{X#a)N@_ zPz6kqr3-|d!VIRd%*nIPuPvle!7RSv*&YXkqGuaAWogP1h*I-99^eaBfS^y3GzUqB zX?2Yj0eXIdl270a_b*Xq@)g5;zsfo8{VM-~xJonNr>U9%1an@6ANyKg{Re08TEPGS literal 0 HcmV?d00001 diff --git a/project2/src/main/java/cyou/chenx221/pojo/Password.java b/project2/src/main/java/cyou/chenx221/pojo/Password.java new file mode 100644 index 0000000..d098d94 --- /dev/null +++ b/project2/src/main/java/cyou/chenx221/pojo/Password.java @@ -0,0 +1,36 @@ +package cyou.chenx221.pojo; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Password { + private String password; + private String encryptedPassword; + + public Password() { + } + + public Password(String password) throws NoSuchAlgorithmException { + encryptedPassword = encryptPassword(password); + } + + private String encryptPassword(String password) throws NoSuchAlgorithmException { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + byte[] hash = digest.digest(password.getBytes()); + + StringBuilder hexString = new StringBuilder(); + for (byte b : hash) { + String hex = Integer.toHexString(0xff & b); + if (hex.length() == 1) { + hexString.append('0'); + } + hexString.append(hex); + } + return hexString.toString(); + } + + public String getEncryptedPassword() { + return encryptedPassword; + } + +}