WangHan
2025-04-03 a1b85ef72062ca80db35546e4216dd564f3e0f57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//package com.iplatform.security;
//
//import com.iplatform.base.util.PlatformRSAUtils;
//import com.walker.infrastructure.utils.Base64;
//import com.walker.infrastructure.utils.Base64Utils;
//import com.walker.infrastructure.utils.RSAUtil;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//
//import java.security.KeyFactory;
//import java.security.PrivateKey;
//import java.security.spec.PKCS8EncodedKeySpec;
//
//public class TestSecurity {
//
////    @Test
//    public void testDecryptPassword() throws Exception{
//        String encodePass = "DOEUaXiOa0y8Kq0De+P4OL/bdydlEFC+330I2lmXbz8VwHJYugLV/IPeXp31fZ5yOQvelMLwDutNtgQaRVS9L8n5ctjpYQZC3HAVDZ+6sXhE3TIH14Q8S3RhD3kE8iBVKrWd7423iCjflNwUPedFcQ0zVpJt3pC3wvDUayXIJnI=";
////        String decode = Base64.decodeBase64(encode.getBytes(StandardCharsets.UTF_8));
//
//        byte[] keyBytes = Base64Utils.decode(PlatformRSAUtils.PRIK);
//        PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(keyBytes);
//        KeyFactory keyFactory = KeyFactory.getInstance("RSA");
//        PrivateKey privateK = keyFactory.generatePrivate(pkcs8KeySpec);
//
//        String password = RSAUtil.decrypt(privateK, Base64.decode(encodePass.getBytes()));
//        System.out.println(password);
//    }
//
////    @Test
//    public void testGeneratePassword(){
//        String raw = "123456";
//        BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
//        String encrypt = passwordEncoder.encode(raw);
//        System.out.println("encrypt = " + encrypt);
//    }
//}