Search in sources :

Example 1 with ByteArrayTool

use of io.nuls.core.utils.crypto.ByteArrayTool in project nuls by nuls-io.

the class KeyValue method toByte.

public byte[] toByte() {
    ByteArrayTool byteArray = new ByteArrayTool();
    try {
        byte[] codeBytes = code.getBytes(CHARSET);
        byteArray.append(codeBytes.length);
        byteArray.append(codeBytes);
        byte[] nameBytes = name.getBytes(CHARSET);
        byteArray.append(nameBytes.length);
        byteArray.append(nameBytes);
        byteArray.append(new VarInt(value.length).encode());
        byteArray.append(value);
    } catch (UnsupportedEncodingException e) {
        Log.error(e);
    }
    return byteArray.toArray();
}
Also used : ByteArrayTool(io.nuls.core.utils.crypto.ByteArrayTool) VarInt(io.nuls.core.crypto.VarInt) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

VarInt (io.nuls.core.crypto.VarInt)1 ByteArrayTool (io.nuls.core.utils.crypto.ByteArrayTool)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1