Guest User

Untitled

a guest
Oct 12th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. private void encrptString()
  2. {
  3. sample = "<xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  4. String encrypt = Encoder.BuilderAES()
  5. .message(sample)
  6. .method(AES.Method.AES_ECB_PKCS5PADDING)
  7. .key("qwertyuiopasdfgh")
  8. .keySize(AES.Key.SIZE_128)
  9. .encrypt();
  10.  
  11. System.out.println("encrypt"+encrypt);
  12.  
  13. String stringFromBase = new String(Base64.decode(encrypt,Base64.DEFAULT));
  14. System.out.println("base64"+stringFromBase.trim());
  15.  
  16.  
  17.  
  18. String hex= null;
  19. try {
  20. hex = toHex(stringFromBase);
  21. } catch (UnsupportedEncodingException e) {
  22. e.printStackTrace();
  23. }
  24. Toast.makeText(this, hex, Toast.LENGTH_SHORT).show();
  25. System.out.println("hex"+hex.trim());
  26.  
  27.  
  28. }
  29.  
  30. public String toHex(String arg) throws UnsupportedEncodingException {
  31. return String.format("%040x", new BigInteger(1, arg.getBytes("UTF-8")));
  32.  
  33.  
  34. }
Add Comment
Please, Sign In to add comment