summaryrefslogtreecommitdiff
path: root/src/main/java/com/keuin/kbackupfabric/backup/incremental/identifier/Sha256IdentifierConverter.java
blob: a8ec77c09440d922f86d30fffcea5c782c5263b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package com.keuin.kbackupfabric.backup.incremental.identifier;

import com.keuin.kbackupfabric.util.backup.incremental.identifier.SingleHashIdentifier;

import java.lang.reflect.Field;

public class Sha256IdentifierConverter {
    public static Sha256Identifier convert(com.keuin.kbackupfabric.util.backup.incremental.identifier.Sha256Identifier old) throws NoSuchFieldException, IllegalAccessException {
        Field field = ((SingleHashIdentifier) old).getClass().getSuperclass().getDeclaredField("hash");
        field.setAccessible(true);
        byte[] hash = (byte[]) field.get(old);
        return new Sha256Identifier(hash);
    }
}