private byte[] convertPasswordToKey(byte[] password){
  try {
    MessageDigest md=MessageDigest.getInstance("SHA");
    byte[] seed=md.digest(password);
    SecureRandom random=SecureRandom.getInstance("SHA1PRNG");
    random.setSeed(seed);
    byte[] rawkey=new byte[keyLength];
    random.nextBytes(rawkey);
    return rawkey;
  }
 catch (  Exception e) {
    throw new RuntimeException(e);
  }
}

private byte [ ] convertPasswordToKey ( byte [ ] password ) { try { MessageDigest md = MessageDigest . getInstance ( "SHA" ) ; byte [ ] seed = md . digest ( password ) ; SecureRandom random = SecureRandom . getInstance ( "SHA1PRNG" ) ; random . setSeed ( seed ) ; byte [ ] rawkey = new byte [ keyLength ] ; random . nextBytes ( rawkey ) ; return rawkey ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
this method converts the specified password into a key in a deterministic manner . the key is then usable for creating ciphers and macs .
