CS 342 - 11/9/17
Java Lambda Expressions
lambda expressions expand into an annonymous inner class
The code:
button.addActionListener ( e -> displayMessage(e) );
Expands into:
button.addActionListener ( new ActionListener (){
void actionPerformed (ActionEvent e)
{
displayMessage(e)
}});
This happens because:
1. addActionListener ( ) takes an interface as its only parameter (it is not overloaded)
2. the interface only specifies 1 method
3. The lambda expression portion before the ->
corresponds to the parameters of the method
4. The lambda expression portion after the ->
corresponds to the body of the method
---------------------------------
RSA Encryption public/private key algorithm
Start with 2 prime values: p, q
Compute 3 more values:
n = p * q
d, e (how to compute coming later)
private key pair is (don't share with anyone)
public key pair is (give this to everyone)
To encrypt a message M to send to user U
we first need U's public key
M' = M^e % n
Now we can send M' to user U. U decrypt the message M' by
M'^d %n ===> M
The key to this is that it is very hard to determine d
from knowing e, n.