刘光辉
4 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
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
package jnpf.dmsEntity.storage;
 
import jnpf.dmsEntity.storage.enums.DmsWorkflowFileType;
 
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;
 
public final class DmsWorkflowSourceKey {
    private DmsWorkflowSourceKey() {
    }
 
    public static String of(String flowId, String taskId, DmsWorkflowFileType type) {
        String flow = flowId.trim();
        String task = taskId.trim();
        String identity = type.name() + ":" + flow.length() + ":" + flow + ":" + task;
        try {
            return "workflow:" + HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256")
                    .digest(identity.getBytes(StandardCharsets.UTF_8)));
        } catch (NoSuchAlgorithmException exception) {
            throw new IllegalStateException(exception);
        }
    }
}