aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/utils/UrlUtil.java
blob: 50c4228837d30ab22430c6400c5d76b43aaad0b7 (plain)
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 de.thedevstack.conversationsplus.utils;

import java.net.URL;

import eu.siacs.conversations.utils.CryptoHelper;

/**
 * This utility class provides helper methods to handle URLs.
 */

public final class UrlUtil {
    public static byte[] getIvAndKeyFromURL(URL url) {
        if (null == url) {
            return null;
        }
        String reference = url.getRef();
        boolean linkHasIvAndKey = reference != null && reference.matches("([A-Fa-f0-9]{2}){48}");

        return linkHasIvAndKey ? CryptoHelper.hexToBytes(reference) : null;
    }

    private UrlUtil() {
        // Helper Class
    }
}