Skip to content

Instantly share code, notes, and snippets.

@maio
Created February 26, 2009 14:27
Show Gist options
  • Save maio/70875 to your computer and use it in GitHub Desktop.
Save maio/70875 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "LoloCrypt"
RESOLVER ( (* TSOLAR) (* PUBLIC) )
AS
import java.lang.*;
import java.io.*;
import oracle.security.crypto.core.*;
import oracle.security.crypto.util.*;
public class LoloCrypt {
public static String RSAEncrypt(String data, String pubKey_base64) {
try {
RSAPublicKey pubKey =
new RSAPublicKey(Utils.fromBase64(pubKey_base64));
Cipher rsaEnc =
Cipher.getInstance(AlgID.rsaWithOAEPEncoding, pubKey);
return Utils.toBase64(rsaEnc.encrypt(data.getBytes()));
}
catch (Exception e) {
return "error: " + e.toString();
}
}
};
/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment