|
|
@@ -7,9 +7,7 @@ import com.google.common.base.Splitter;
|
|
|
import com.izouma.nineth.config.Constants;
|
|
|
import com.izouma.nineth.domain.BaseEntity;
|
|
|
import com.izouma.nineth.domain.BlindBoxItem;
|
|
|
-import com.izouma.nineth.domain.TestClass;
|
|
|
import com.izouma.nineth.domain.User;
|
|
|
-import com.izouma.nineth.enums.AuthStatus;
|
|
|
import com.izouma.nineth.utils.AESEncryptUtil;
|
|
|
import com.izouma.nineth.utils.TokenUtils;
|
|
|
import com.izouma.nineth.web.BaseController;
|
|
|
@@ -462,19 +460,44 @@ public class CommonTest {
|
|
|
|
|
|
|
|
|
@Test
|
|
|
- public void asdfsad() {
|
|
|
- long t = System.currentTimeMillis();
|
|
|
- User user = new User();
|
|
|
- user.setUsername("342353315");
|
|
|
- user.setPhone("123123123");
|
|
|
- user.setShareRatio(BigDecimal.ZERO);
|
|
|
- user.setAuthStatus(AuthStatus.NOT_AUTH);
|
|
|
- System.out.println(System.currentTimeMillis() - t + "ms");
|
|
|
+ public void testBCrypt() {
|
|
|
+ BCryptPasswordEncoder encoder1 = new BCryptPasswordEncoder(4);
|
|
|
+ BCryptPasswordEncoder encoder2 = new BCryptPasswordEncoder(4);
|
|
|
+ String pwd = "$2a$10$oAWnGIHR2Cvc0BsMN7YCtOjvXsBLBygYxiVG3E1fuUmhM3sEOYhQe";
|
|
|
+
|
|
|
+ System.out.println(encoder1.matches("123456", pwd));
|
|
|
+ System.out.println(encoder2.matches("123456", pwd));
|
|
|
+
|
|
|
+ System.out.println(encoder1.matches("1234561", pwd));
|
|
|
+ System.out.println(encoder2.matches("1234561", pwd));
|
|
|
+
|
|
|
+ long encode1 = 0;
|
|
|
+ long match1 = 0;
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ long t = System.currentTimeMillis();
|
|
|
+ encoder1.encode("123456");
|
|
|
+ encode1 += System.currentTimeMillis() - t;
|
|
|
+
|
|
|
+ t = System.currentTimeMillis();
|
|
|
+ encoder1.matches("123456", pwd);
|
|
|
+ match1 += System.currentTimeMillis() - t;
|
|
|
+ }
|
|
|
+ System.out.println("avg encode = " + encode1 / 10 + "ms");
|
|
|
+ System.out.println("avg match = " + match1 / 10 + "ms");
|
|
|
|
|
|
|
|
|
- long t1 = System.currentTimeMillis();
|
|
|
- TestClass testClass = new TestClass();
|
|
|
+ long encode2 = 0;
|
|
|
+ long match2 = 0;
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
+ long t = System.currentTimeMillis();
|
|
|
+ encoder2.encode("123456");
|
|
|
+ encode2 += System.currentTimeMillis() - t;
|
|
|
|
|
|
- System.out.println(System.currentTimeMillis() - t1 + "ms");
|
|
|
+ t = System.currentTimeMillis();
|
|
|
+ encoder2.matches("123456", pwd);
|
|
|
+ match2 += System.currentTimeMillis() - t;
|
|
|
+ }
|
|
|
+ System.out.println("avg encode = " + encode2 / 10 + "ms");
|
|
|
+ System.out.println("avg match = " + match2 / 10 + "ms");
|
|
|
}
|
|
|
}
|