Exporter
File
Decode hex with web3j
For Copy hex · org.web3j:crypto · tested with 4.8.7 and 4.14.0
static byte[] decodeHex(String rawHex) {
RawTransaction tx = TransactionDecoder.decode(rawHex);
return Numeric.hexStringToByteArray(tx.getData());
}
Files.write(Paths.get("/path/to/sample.txt"), decodeHex("0x…"));
Decode binary with web3j
For Download · org.web3j:crypto · tested with 4.8.7 and 4.14.0
static byte[] decodeBinary(Path rawTxFile) throws IOException {
byte[] rawTx = Files.readAllBytes(rawTxFile);
RawTransaction tx = TransactionDecoder.decode(Numeric.toHexString(rawTx));
return Numeric.hexStringToByteArray(tx.getData());
}
Files.write(Paths.get("/path/to/sample.txt"), decodeBinary(Paths.get("/path/to/sample-rawtx.txt")));
Decode xlsx with web3j
For Download as xlsx · org.web3j:crypto 4.14.0 + org.apache.poi:poi-ooxml 5.4.1
static byte[] decodeXlsx(Path xlsxFile) throws IOException {
StringBuilder rawHex = new StringBuilder();
try (Workbook wb = WorkbookFactory.create(xlsxFile.toFile())) {
for (Cell cell : wb.getSheetAt(0).getRow(0)) rawHex.append(cell.getStringCellValue());
}
RawTransaction tx = TransactionDecoder.decode(rawHex.toString());
return Numeric.hexStringToByteArray(tx.getData());
}
Files.write(Paths.get("/path/to/sample.txt"), decodeXlsx(Paths.get("/path/to/sample-rawtx.xlsx")));
Decode png with web3j
For Download as png · org.web3j:crypto 4.14.0 + javax.imageio
static byte[] decodePng(Path pngFile) throws IOException {
BufferedImage img = ImageIO.read(pngFile.toFile());
ByteArrayOutputStream pixels = new ByteArrayOutputStream();
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int rgb = img.getRGB(x, y);
pixels.write(rgb >> 16);
pixels.write(rgb >> 8);
pixels.write(rgb);
}
}
byte[] bytes = pixels.toByteArray();
byte[] rawTx = Arrays.copyOfRange(bytes, 4, 4 + ByteBuffer.wrap(bytes).getInt());
RawTransaction tx = TransactionDecoder.decode(Numeric.toHexString(rawTx));
return Numeric.hexStringToByteArray(tx.getData());
}
Files.write(Paths.get("/path/to/sample.txt"), decodePng(Paths.get("/path/to/sample-rawtx.png")));
File
Decode png with Java
password is null when Encrypt was off; otherwise the png holds the openssl aes256 -pbkdf2 format: Salted__ + salt, PBKDF2-SHA256, 10000 iterations · JDK only
static byte[] decodePng(Path pngFile, String password) throws Exception {
BufferedImage img = ImageIO.read(pngFile.toFile());
ByteArrayOutputStream pixels = new ByteArrayOutputStream();
for (int y = 0; y < img.getHeight(); y++) {
for (int x = 0; x < img.getWidth(); x++) {
int rgb = img.getRGB(x, y);
pixels.write(rgb >> 16);
pixels.write(rgb >> 8);
pixels.write(rgb);
}
}
byte[] bytes = pixels.toByteArray();
byte[] payload = Arrays.copyOfRange(bytes, 4, 4 + ByteBuffer.wrap(bytes).getInt());
if (password == null) return payload;
// Java 8 before 8u161 caps AES at 128 bits unless this is set (8u151+) or the JCE policy files are installed
Security.setProperty("crypto.policy", "unlimited");
byte[] salt = Arrays.copyOfRange(payload, 8, 16);
SecretKeyFactory kdf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
byte[] keyIv = kdf.generateSecret(new PBEKeySpec(password.toCharArray(), salt, 10000, 384)).getEncoded();
Cipher aes = Cipher.getInstance("AES/CBC/PKCS5Padding");
aes.init(Cipher.DECRYPT_MODE, new SecretKeySpec(keyIv, 0, 32, "AES"), new IvParameterSpec(keyIv, 32, 16));
return aes.doFinal(payload, 16, payload.length - 16);
}
Files.write(Paths.get("/path/to/sample.txt"), decodePng(Paths.get("/path/to/sample-plain.png"), null));
Files.write(Paths.get("/path/to/sample.txt"), decodePng(Paths.get("/path/to/sample-enc.png"), "…"));
Input
Type, paste, or drop a file anywhere on the page. Nothing leaves the page and nothing is stored.
Base64
or
Commands
These follow the settings above. Click a line to copy it.
Base64
Paste it, or drop the parts (or the zip holding them) anywhere on the page. Files are merged in name order.
Decoded
Commands
The shell equivalent, if the parts landed on a machine without a browser.