package crypto.ciphers.asy.rsa;

import java.math.BigInteger;
import javafx.util.Pair;
import org.junit.Test;
import static org.junit.Assert.*;

import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Ignore;

/**
 *
 * @author Victor de Lima Soares
 */
public class RSATest {

    public RSATest() {
    }

    private final RSA rsa = new RSA(512);

    /**
     * Test of encrypt method, of class RSA.
     */
    @Test
    public void testEncrypt_Pair_String() {
        System.out.println("encrypt");

        String plainText = "test";
        BigInteger cipherText = RSA.encrypt(rsa.getPublicKeyPair(), plainText);
        String decryptedText = RSA.BigIntegerToString(rsa.decrypt(cipherText));
        System.out.println(plainText);
        System.out.println(decryptedText);
        assertEquals("enc/dec", plainText, decryptedText);
    }


    /**
     * Test of encrypt method, of class RSA.
     */
    @Test
    public void testEncrypt_Pair_BigInteger() {
        System.out.println("encrypt");
        BigInteger msg = BigInteger.TEN;
        BigInteger expResult = BigInteger.TEN;
        BigInteger cipherMsg = RSA.encrypt(rsa.getPublicKeyPair(), msg);
        BigInteger decryptedMsg = rsa.decrypt(cipherMsg);
        System.out.println(msg);
        System.out.println(decryptedMsg);
        assertEquals("enc/dec",expResult, decryptedMsg);
    }

}

@@ -39,28 +39,182 @@
 ort 
-java.math.BigInteger
+crypto.ciphers.block.feistel.des.DES;%0D%0Aimport java.math.BigInteger;%0D%0Aimport java.nio.charset.Charset;%0D%0Aimport java.security.NoSuchAlgorithmException;%0D%0Aimport java.util.Arrays
 ;%0D%0Ai
@@ -732,16 +732,26 @@
  = %22test
+ABCDEabcde
 %22;%0D%0A    
@@ -940,32 +940,124 @@
 ln(plainText);%0D%0A
+        System.out.println(Arrays.toString(plainText.getBytes(Charset.forName(%22utf-8%22))));%0D%0A
         System.o
@@ -1153,18 +1153,16 @@
    %7D%0D%0A%0D%0A
-%0D%0A
     /**%0D
@@ -1648,16 +1648,17 @@
 nc/dec%22,
+ 
 expResul
@@ -1685,11 +1685,699 @@
    %7D%0D%0A%0D%0A
+    /**%0D%0A     * Test of encrypt method, of class RSA.%0D%0A     */%0D%0A    @Test%0D%0A    public void testEncrypt_Pair_bytes() throws NoSuchAlgorithmException %7B%0D%0A        System.out.println(%22encrypt%22);%0D%0A        byte%5B%5D newKey = DES.genkey(true);%0D%0A        //byte%5B%5D newKey = %7B-10,-1,-90,0,0,5%7D;%0D%0A        byte%5B%5D expResult = newKey.clone();%0D%0A        %0D%0A        BigInteger cipherMsg = RSA.encrypt(rsa.getPublicKeyPair(), new BigInteger(newKey) );%0D%0A        byte%5B%5D decryptedMsg = rsa.decrypt(cipherMsg).toByteArray();%0D%0A        System.out.println(Arrays.toString(expResult));%0D%0A        System.out.println(Arrays.toString(decryptedMsg));%0D%0A        assertArrayEquals(%22enc/dec%22, expResult, decryptedMsg);%0D%0A%0D%0A    %7D%0D%0A
 %7D%0D%0A

Fix key generation on DES to be used with BigIntegers.