public class DataUtils extends Object
Constructor and Description |
---|
DataUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
byteArrayToHexString(byte[] bytes)
Convert a byte array into a hexadecimal string (lowercase).
|
static byte[] |
hexStringToByteArray(String s)
Convert a string in hexadecimal representation to a byte array.
|
static byte[] |
readHexFile(File inFile)
Read hexadecimal data from a file and return it as a byte array.
|
static Key |
readKeyFile(File inFile)
Read an encoded key from a file and return it as a key instance.
|
static Key |
readKeyFile(File inFile,
String expectedKeyType)
Read an encoded key from a file and return it as a key instance.
|
static void |
writeHexFile(File outFile,
byte[] data)
Write a byte array into a file in hexadecimal format.
|
static void |
writeKeyFile(File outFile,
Key key)
Write an encoded key to a file
Encoded key format: type:hex_key.
|
public static byte[] hexStringToByteArray(String s)
s
- hex stringpublic static String byteArrayToHexString(byte[] bytes)
bytes
- the bytes to encodepublic static byte[] readHexFile(File inFile) throws IOException
inFile
- input fileIOException
public static void writeHexFile(File outFile, byte[] data) throws IOException
outFile
- output filedata
- the data to be writtenIOException
public static Key readKeyFile(File inFile) throws IOException, InvalidKeyException
inFile
- input fileIOException
InvalidKeyException
public static Key readKeyFile(File inFile, String expectedKeyType) throws IOException, InvalidKeyException
inFile
- input fileexpectedKeyType
- validates the key type (private or public)IOException
InvalidKeyException
public static void writeKeyFile(File outFile, Key key) throws IOException
outFile
- output filekey
- a key that will be encoded and written to a fileIOException
Copyright © 2015 Threema GmbH, Staldenbachstrasse 11, 8808 Pfäffikon SZ, Schweiz. All rights reserved.