Advertisement
Guest User

Untitled

a guest
Oct 19th, 2013
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. public String decrypt(String dec) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException {
  2.        
  3.         InputStream mybyte = new ByteArrayInputStream(dec.getBytes());
  4.        
  5.         SecretKeySpec sks = new SecretKeySpec("MyDifficultPassw".getBytes(), "AES");
  6.         Cipher cipher = Cipher.getInstance("AES");
  7.         cipher.init(Cipher.DECRYPT_MODE, sks);
  8.         CipherInputStream cis = new CipherInputStream(mybyte, cipher);
  9.         int b;
  10.         byte[] d = new byte[8];
  11.         String s="";
  12.         while((b = cis.read(d)) != -1) {
  13.             //fos.write(d, 0, b);
  14.             s+=b;
  15.         }
  16.        
  17.         Toast.makeText(this,s,Toast.LENGTH_LONG).show();
  18.        
  19.         cis.close();
  20.        
  21.         return s;
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement