summaryrefslogtreecommitdiffstats
blob: 8dda1c213a4b5176556607b16b42121b3d733a51 (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
/*
 * Copyright (c) 2011 Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010 Remko Tronçon.
 * All rights reserved.
 */
package com.isode.stroke.stringcodecs;

import com.isode.stroke.base.ByteArray;

public class Hexify {

    public static String hexify(byte datum) {
        return String.format("%x", new Byte(datum));
    }

    public static String hexify(ByteArray data) {
        StringBuilder result = new StringBuilder();
        for (byte b : data.getData()) {
            result.append(hexify(b));
        }
        return result.toString();
    }
}