Transcript Slide 1

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:


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)


void init(SecureRandom random)


Generates a KeyGenerator object for the specified algorithm.
Initializes this key generator.
SecretKey generateKey()

Generates a secret key.
Cipher,

static Cipher getInstance(String transformation)


void init(int opmode, Key key)


Generates a Cipher object that implements the specified
transformation. You can use “DES/ECB/PKCS5Padding”
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.
CipherOutputstream
CipherInputstream

CipherOutputStream(OutputStream os, Cipher c)


void write(byte[] b)


Constructs a CipherInputStream from an InputStream and a Cipher.
int read(byte[] b)


Writes b.length bytes from the specified byte array to this output stream.
CipherInputStream(InputStream is, Cipher c)


Constructs a CipherOutputStream from an OutputStream and a Cipher.
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)


x/y mod z


BigInteger.valueOf(1)
X.multiply(y.modPow(kOne.negate(), z)).mod(z)
k relatively prime to z

k.gcd(z).equals(kOne) == true