Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NumberParsing.java « test « util « bouncycastle « org « java « main « src « core - gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a060dd8e8262c07db492942252e10cea1506c284 (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
26
27
28
29
30
31
32
33
34
package org.bouncycastle.util.test;

/**
 * Parsing
 */
public final class NumberParsing
{
    private NumberParsing() 
    {
        // Hide constructor
    }
    
    public static long decodeLongFromHex(String longAsString) 
    {
        if ((longAsString.charAt(1) == 'x')
            || (longAsString.charAt(1) == 'X'))
        {
            return Long.parseLong(longAsString.substring(2), 16);
        }

        return Long.parseLong(longAsString, 16);
    }
    
    public static int decodeIntFromHex(String intAsString)
    {
        if ((intAsString.charAt(1) == 'x')
            || (intAsString.charAt(1) == 'X'))
        {
            return Integer.parseInt(intAsString.substring(2), 16);
        }

        return Integer.parseInt(intAsString, 16);
    }
}