This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.crypto.Cipher; | |
import java.nio.charset.StandardCharsets; | |
import java.security.KeyPair; | |
import java.security.KeyPairGenerator; | |
import java.security.SecureRandom; | |
import java.security.Signature; | |
public class RsaExample { | |
public static void main(String... argv) throws Exception { | |
//First generate a public/private key pair |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// allows converting one class to another by providing missing fields | |
object convert { | |
@annotation.implicitNotFound(""" | |
You have not provided enough arguments to convert from ${In} to ${Out}. | |
${Args} | |
""") | |
trait Convertible[Args, In, Out] { | |
def apply(args: Args, in: In): Out | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import java.security._ | |
import java.security.spec.X509EncodedKeySpec | |
import javax.crypto._ | |
import org.apache.commons.codec.binary.Base64 | |
object RSA { | |
def decodePublicKey(encodedKey: String): Option[PublicKey] = { | |
this.decodePublicKey( |