Advertisement
Guest User

Test 3Des

a guest
Nov 27th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package cl.devetel;
  2.  
  3. import java.io.IOException;
  4. import java.io.ByteArrayInputStream;
  5. import java.security.GeneralSecurityException;
  6. import java.io.InputStream;
  7. import org.apache.commons.io.IOUtils;
  8. import org.apache.commons.ssl.OpenSSL;
  9.  
  10. public class TresDesDevpay {
  11.  
  12.     byte[] password = "ABCDEFGHIJKLMNOPQRSTUVWX".getBytes();
  13.     byte[] data = "".getBytes();
  14.  
  15.  
  16.     public String cifrar(String str) throws IOException, GeneralSecurityException{
  17.  
  18.         InputStream encrypted = OpenSSL.encrypt("des3",password,new ByteArrayInputStream(str.getBytes()),true);
  19.         return IOUtils.toString(encrypted);
  20.     }
  21.  
  22.     // Encrypt!
  23.  
  24. //  // Decrypt results of previous!
  25. //  public String decifrar(String str) throws IOException, GeneralSecurityException{
  26. //      data = OpenSSL.decrypt("des3", password, str.getBytes());
  27. //      return  new String(data);
  28. //  }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement