java.lang.Object
javax.crypto.spec.SecretKeySpec
- All Implemented Interfaces:
- Serializable, Key, KeySpec, SecretKey
- See Also:
- Top Examples, Source Code,
SecretKeyFactory
public boolean equals(Object obj)
- See Also:
Hashtable
, Object.hashCode()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[529]Generate a SecretKey
By Anonymous on 2003/11/17 10:36:55 Rate
import java.security.*;
importjavax.crypto.*;
// Get Provider
Provider sunJce = new com.sun.crypto.provider.SunJCE ( ) ;
// Obtain Cipher AES available 1.4.2
Cipher c = Cipher.getInstance ( "AES" ) ;
// Get the key Generator
KeyGenerator kgen = KeyGenerator.getInstance ( "AES" ) ;
// Generate the key specs
SecretKey skey = kgen.generateKey ( ) ;
byte [ ] raw = skey.getEncoded ( ) ;
SecretKeySpec kspec = new
SecretKeySpec ( raw, "AES" ) ;
// Initialize cipher with keys, etc.
cipher.init ( Cipher.ENCRYPT_MODE, kspec ) ;
// Update buffers
while ( msg [ i ] != null )
enc = cipher.update ( msg [ i ] .getBytes ( ) ) ;
// Finish up
enc = cipher.doFinal ( ) ;
//equals
public String getAlgorithm()
- See Also:
- Key
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public byte[] getEncoded()
- See Also:
- Key
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public String getFormat()
- See Also:
- Key
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public int hashCode()
- See Also:
Hashtable
, Object.equals(java.lang.Object)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public SecretKeySpec(byte[] key,
int offset,
int len,
String algorithm)
- See Also:
- ArrayIndexOutOfBoundsException, IllegalArgumentException,
DESKeySpec
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public SecretKeySpec(byte[] key,
String algorithm)
- See Also:
- IllegalArgumentException,
DESKeySpec
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples