summaryrefslogtreecommitdiffstats
path: root/src/main/java/com/kitfox/svg/xml/Base64Util.java
blob: a95b9d4fdf2876507a8419e9b147ece979d3d261 (plain) (blame)
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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.kitfox.svg.xml;

/**
 *
 * @author kitfox
 */
public class Base64Util 
{
    static final byte[] valueToBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".getBytes();
    static final byte[] base64ToValue = new byte[128];
    static {
        for (int i = 0; i < valueToBase64.length; ++i)
        {
            base64ToValue[valueToBase64[i]] = (byte)i;
        }
    }
    
    static public byte encodeByte(int value)
    {
        return valueToBase64[value];
    }
    
    static public byte decodeByte(int base64Char)
    {
        return base64ToValue[base64Char];
    }
}