Skip to content

Instantly share code, notes, and snippets.

View fwrq41251's full-sized avatar

winry fwrq41251

View GitHub Profile
@nielsutrecht
nielsutrecht / RsaExample.java
Created December 21, 2016 09:55
Example of using RSA in Java to sign/verify and encrypt/decryt
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
// 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
}
@urcadox
urcadox / RSA.scala
Created August 7, 2013 12:57
RSA encryption in Scala
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(