60 likes | 78 Views
Java Assignment Related. Message digest. MessageDigest class getInstance(“SHA”) update(byte []) dijest(); digest(byte []) Producing byte array DataOutputStream to ByteOutputStream Write data types: writeLong(l) toByteArray in ByteOutputStream. Key, KeyGenerator. Key:
E N D
Message digest • MessageDigest class • getInstance(“SHA”) • update(byte []) • dijest(); digest(byte []) • Producing byte array • DataOutputStream to ByteOutputStream • Write data types: writeLong(l) • toByteArray in ByteOutputStream
Key, KeyGenerator • Key: • top-level interface for all keys. defines the functionality of all key objects. • KeyGenerator: • This class provides the functionality of a (symmetric) key generator. • static KeyGenerator getInstance(String algorithm) • Generates a KeyGenerator object for the specified algorithm. • void init(SecureRandom random) • Initializes this key generator. • SecretKey generateKey() • Generates a secret key.
Cipher, • static Cipher getInstance(String transformation) • Generates a Cipher object that implements the specified transformation. You can use “DES/ECB/PKCS5Padding” • void init(int opmode, Key key) • Initializes this cipher with a key. • Field Detail • public static final int ENCRYPT_MODE • Constant used to initialize cipher to encryption mode. • public static final int DECRYPT_MODE • Constant used to initialize cipher to decryption mode.
CipherOutputstreamCipherInputstream • CipherOutputStream(OutputStream os, Cipher c) • Constructs a CipherOutputStream from an OutputStream and a Cipher. • void write(byte[] b) • Writes b.length bytes from the specified byte array to this output stream. • CipherInputStream(InputStream is, Cipher c) • Constructs a CipherInputStream from an InputStream and a Cipher. • int read(byte[] b) • Reads up to b.length bytes of data from this input stream into an array of bytes. • void close() • Closes this output/input stream and releases any system resources associated with this stream.
Big Integer • BeigInteger(1, messagebytes) • BigInteger.valueOf(1) • x/y mod z • X.multiply(y.modPow(kOne.negate(), z)).mod(z) • k relatively prime to z • k.gcd(z).equals(kOne) == true