Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void encrptString()
- {
- sample = "<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
- String encrypt = Encoder.BuilderAES()
- .message(sample)
- .method(AES.Method.AES_ECB_PKCS5PADDING)
- .key("qwertyuiopasdfgh")
- .keySize(AES.Key.SIZE_128)
- .encrypt();
- System.out.println("encrypt"+encrypt);
- String stringFromBase = new String(Base64.decode(encrypt,Base64.DEFAULT));
- System.out.println("base64"+stringFromBase.trim());
- String hex= null;
- try {
- hex = toHex(stringFromBase);
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- Toast.makeText(this, hex, Toast.LENGTH_SHORT).show();
- System.out.println("hex"+hex.trim());
- }
- public String toHex(String arg) throws UnsupportedEncodingException {
- return String.format("%040x", new BigInteger(1, arg.getBytes("UTF-8")));
- }
Add Comment
Please, Sign In to add comment