Package com.oceanprotocol.squid.helpers
Class EncodingHelper
- java.lang.Object
-
- com.oceanprotocol.squid.helpers.EncodingHelper
-
public abstract class EncodingHelper extends Object
-
-
Constructor Summary
Constructors Constructor Description EncodingHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
byteArrayToByteArray32(byte[] byteValue)
Given a byte array returns the first 32 bytes in a new byte arraystatic String
encodeToHex(String input)
Encodes a String in Hexstatic String
hexEncodeAbiType(String type, Object value)
Given a type and an object, convert to the proper web3j abi typestatic byte[]
hexStringToBytes(String input)
Encodes a Hex String in a byte arraystatic boolean
isHexString(String input)
Return true or false if a input string is in hex formatstatic String
padRightWithZero(String input, int len)
Pad a string with zero given a specific lengthstatic String
signatureToString(org.web3j.crypto.Sign.SignatureData signatureData)
static byte[]
stringToBytes(String input)
Convert a string to hex and after to a byte arraystatic org.web3j.abi.datatypes.generated.Bytes32
stringToBytes32(String input)
Given a String return a Bytes32static org.web3j.crypto.Sign.SignatureData
stringToSignature(String signatureString)
static String
toHexString(byte[] input)
Convert a byte[] to a hex string with 0x appended
-
-
-
Method Detail
-
stringToBytes32
public static org.web3j.abi.datatypes.generated.Bytes32 stringToBytes32(String input)
Given a String return a Bytes32- Parameters:
input
- input string- Returns:
- Bytes32 output
-
byteArrayToByteArray32
public static byte[] byteArrayToByteArray32(byte[] byteValue)
Given a byte array returns the first 32 bytes in a new byte array- Parameters:
byteValue
- byte[]- Returns:
- byte[]
-
encodeToHex
public static String encodeToHex(String input) throws UnsupportedEncodingException
Encodes a String in Hex- Parameters:
input
- string to encode- Returns:
- Hex string
- Throws:
UnsupportedEncodingException
- Error encoding to Hex
-
hexStringToBytes
public static byte[] hexStringToBytes(String input) throws UnsupportedEncodingException
Encodes a Hex String in a byte array- Parameters:
input
- hex string to encode- Returns:
- byte[]
- Throws:
UnsupportedEncodingException
- Error encoding to byte array
-
stringToBytes
public static byte[] stringToBytes(String input) throws UnsupportedEncodingException
Convert a string to hex and after to a byte array- Parameters:
input
- string to encode- Returns:
- byte[]
- Throws:
UnsupportedEncodingException
- Error encoding to byte array
-
padRightWithZero
public static String padRightWithZero(String input, int len)
Pad a string with zero given a specific length- Parameters:
input
- stringlen
- length of the output string- Returns:
- string
-
toHexString
public static String toHexString(byte[] input)
Convert a byte[] to a hex string with 0x appended- Parameters:
input
- byte[]- Returns:
- hex string
-
isHexString
public static boolean isHexString(String input)
Return true or false if a input string is in hex format- Parameters:
input
- the input string- Returns:
- bool
-
hexEncodeAbiType
public static String hexEncodeAbiType(String type, Object value) throws UnsupportedEncodingException
Given a type and an object, convert to the proper web3j abi type- Parameters:
type
- thw typevalue
- the object- Returns:
- String in hex format
- Throws:
UnsupportedEncodingException
- UnsupportedEncodingException
-
signatureToString
public static String signatureToString(org.web3j.crypto.Sign.SignatureData signatureData)
-
stringToSignature
public static org.web3j.crypto.Sign.SignatureData stringToSignature(String signatureString) throws EncodingException
- Throws:
EncodingException
-
-