summaryrefslogtreecommitdiffstats
blob: 7f51fb97429ef5a3f8a9ccf383a6791afd2b03f1 (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();
    }
}