Results 1 to 4 of 4

Thread: Java encryption

  1. #1
    soul_krasty is offline Member
    Join Date
    Aug 2007
    Posts
    2
    Rep Power
    0

    Question Java encryption

    hello..can anybody help doing this thing.if some one out there are doing something like i did.don't feel shy to discuss.need help ASAP!!!

  2. #2
    shanePreater is offline Member
    Join Date
    Jul 2007
    Location
    England, Bath
    Posts
    47
    Rep Power
    0

    Default

    I would recommend you look into the java cryptography extension (jce)
    JCE main page
    Suns JCE guide

    Have a read through those and then I have included a simple password encoder which I use quite often to perform simple encryptions:
    Java Code:
    package com.onevision.loanmanager.service.helper;
    
    import java.security.MessageDigest;
    
    import org.apache.log4j.Logger;
    
    import sun.misc.BASE64Encoder;
    
    public abstract class PasswordEncoder {
    	private static final String CHARACTER_ENCODING = "UTF-8";
    	private static final String DEFAULT_ALGORITHM = "SHA-256";
    	private static final Logger LOG = Logger.getLogger(PasswordEncoder.class);
    
    	public static String encodePassword(String rawPassword) {
    		return encodePassword(rawPassword, DEFAULT_ALGORITHM);
    	}
    
    	public static String encodePassword(String rawPassword,
    			String encryptionAlgorithm) {
    		MessageDigest md = null;
    		try {
    			md = MessageDigest.getInstance(encryptionAlgorithm); 
    			md.update(rawPassword.getBytes(CHARACTER_ENCODING));
    			byte raw[] = md.digest();
    			String hash = (new BASE64Encoder()).encode(raw);
    			return hash;
    		} catch (Exception e) {
    			LOG.fatal(
    					"Error encrypting the password so returning plain text: ",
    					e);
    		}
    		return rawPassword;
    	}
    }

  3. #3
    soul_krasty is offline Member
    Join Date
    Aug 2007
    Posts
    2
    Rep Power
    0

    Default Hello..

    finally i have install bouncycastle..although i dunno what it will do..actually i am building a java file encrypter.the file that i need to encrypt such as image..mp3..video..small file only..can anu body help me with this.i am using netbean 5:confused:

  4. #4
    khushi is offline Member
    Join Date
    Aug 2007
    Posts
    1
    Rep Power
    0

Similar Threads

  1. Encryption/Decryption
    By Echilon in forum New To Java
    Replies: 2
    Last Post: 03-24-2009, 11:58 AM
  2. encryption
    By Joe2003 in forum Advanced Java
    Replies: 2
    Last Post: 02-06-2008, 10:27 AM
  3. Encryption/Decryption Through AOP
    By SirRawlins in forum Advanced Java
    Replies: 0
    Last Post: 12-19-2007, 03:22 PM
  4. Encryption in java
    By Ed in forum Advanced Java
    Replies: 1
    Last Post: 07-09-2007, 01:47 AM

Posting Permissions

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