Results 1 to 8 of 8
  1. #1
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Smile Encryption and Decryption

    Any built-in functionality available in java for encryption and decryption.

    Please let me know if any functionality available.

    Thanks in Advance..

  2. #2
    sibernewf is offline Member
    Join Date
    Mar 2011
    Posts
    48
    Rep Power
    0

    Default

    There is nothing native in the API that I can recall, but I'm sure you should be able to google examples of how other people have encrypted data.

  3. #3
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    can i use any algorithm from google search for encrypt or decrypt

  4. #4
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    Do you mean like encrypting Strings?

  5. #5
    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0

    Default Try this program dear friend

    Hope this helps you..

    Java Code:
    package org.success.struts.util;
    
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    
    public class PasswordEncryptionUtil {
        /**
         * 
         * @param source
         * @return
         * @throws NoSuchAlgorithmException
         */
        public static String SHA1(String source){
            MessageDigest digest = null;
            try {
                digest = MessageDigest.getInstance("MD5");
            } catch (NoSuchAlgorithmException e) {
                return "";
            }
            byte[] digestedMessage = digest.digest(source.getBytes());
            return getString(digestedMessage);
        }
        
        /**
         * 
         * @param byteSource
         * @return
         */
        private static String getString(byte[] byteSource){
            StringBuffer buffer = new StringBuffer();
            for(byte b : byteSource){
                buffer.append((int)(0x00FF & b));
            }
            return buffer.toString();
        }
        
        public static void main(String[] args) throws NoSuchAlgorithmException {
            System.out.println(PasswordEncryptionUtil.SHA1("beschi"));
        }
    }

  6. #6
    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0

    Default

    But i would suggest that writing your own Encryption and decryption algorithm will be simpler. You can make it efficient with bitwise operators. Explore more...

  7. #7
    d3n1s is offline Member
    Join Date
    Apr 2011
    Posts
    69
    Rep Power
    0

    Default

    Encrypting a String with DES | Example Depot

    This is all you need. I use this to encrypt passwords and store the key as a serialized sealed object. Even the password "a" becomes some incomprehensible gibberish!

  8. #8
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    Convert password string to hexadecimal or any addition or substraction method use
    which is best for password...

Similar Threads

  1. Reg: Image Encryption and Decryption in PGP
    By Deepa in forum New To Java
    Replies: 0
    Last Post: 07-13-2009, 12:13 PM
  2. PGP Encryption&Decryption
    By Deepa in forum New To Java
    Replies: 2
    Last Post: 07-07-2009, 07:22 AM
  3. Encryption/Decryption
    By Echilon in forum New To Java
    Replies: 2
    Last Post: 03-24-2009, 12:58 PM
  4. Encryption-Decryption Problem
    By dinesh.1.sharma in forum Advanced Java
    Replies: 1
    Last Post: 07-17-2008, 11:03 PM
  5. Encryption/Decryption Through AOP
    By SirRawlins in forum Advanced Java
    Replies: 0
    Last Post: 12-19-2007, 04:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •