Can I encrypt a string with RSA encryption using DBMS_CRYPTO?

We have an web application that does a redirect thru a database package to a 3rd party site. They would like us to encrypt the querystring that is passed using RSA encryption. The example that they've given us (below) uses the RSA cryptographic service available in .NET. Is it possible to do this using DBMS_CRYPTO or some other method in Oracle?
Below are the steps outlined to use the key to generate the encrypted URL
2.1 Initialize Service
The RSA cryptographic service must be initialized with the provided public key. Below is sample code that can be used to initialize the service using the public key
C#
private void InitializeRSA( string keyFileName )
CspParameters cspParams = new CspParameters( );
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
m_sp = new RSACryptoServiceProvider( cspParams );
//Load the public key from the supplied XML file
StreamReader reader = new StreamReader( keyFileName );
string data = reader.ReadToEnd( );
//Initializes the public key
m_sp.FromXmlString( data );
2.2 Encryption method
Create a method that will encrypt a string using the cryptographic service that was initialized in step 2.1. The encryption method should convert the encryption method to Base64 to avoid special characters from being passed in the URL. Below is sample code that uses the method created in step 2.1 that can be used to encrypt a string.
C#
private string RSAEncrypt( string plainText )
ASCIIEncoding enc = new ASCIIEncoding( );
int numOfChars = enc.GetByteCount( plainText );
byte[ ] tempArray = enc.GetBytes( plainText );
byte[ ] result = m_sp.Encrypt( tempArray, false );
//Use Base64 encoding since the encrypted string will be used in an URL
return Convert.ToBase64String( result );
2.3 Generate URL
The query string must contain the necessary data elements configured for you school in Step 1. This will always include the Client Number and the Student ID of the student clicking on the link.
1.     Build the query string with Client Number and Student ID
C#
string queryString = “schoolId=1234&studentId=1234”;
The StudentCenter website will validate that the query string was generated within 3 minutes of the request being received on our server. A time stamp in UTC universal time (to prevent time zone inconsistencies) will need to be attached to the query string.
2.     Get the current UTC timestamp, and add the timestamp to the query string
C#
string dateTime = DateTime.UtcNow.ToString(“yyyy-MM-dd HH:mm:ss”);
queryString += “&currentDT=” + dateTime;
Now that the query string has all of the necessary parameters, use the RSAEncrypt (Step 2.2) method created early to encrypt the string. The encrypted string must also be url encoded to escape any special characters.
3.     Encrypt and Url Encode the query string
C#
string rsa = RSAEncrypt(querystring);
string eqs = Server.UrlEncode(rsa);
The encrypted query string is now appended to the Url (https://studentcenter.uhcsr.com), and is now ready for navigation.
4.     Build the URL
C#
string url = “https://studentcenter.uhcsr.com/custom.aspx?eqs=” + eqs

The documentation lists all the encyrption types:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm#ARPLS664

Similar Messages

  • How can i read a string with nextToken() of StreamTokenizer

    I need for my class paper to read a string from a file and i used the StreamTokenizer's method nextToken but i can not read a string with it. my code is:
    StreamTokenizer st = new StreamTokenizer(the code that gets the input from the file)
    String line;
    while ((line !=br.readLine()) != null) {
    String surname = (st.nextToken()).trim();
    but it gets me some error of:
    int can not be dereferenced
    what should I do to get the string i need?

    Look at the API for java.io.StreamTokenizer. In particular, look at the return type for nextToken().
    Good luck.

  • How can i create  excel sheet with multiple tabs using utl file?

    how can i create excel sheet with multiple tabs using utl file?
    any one help me?

    Jaggy,
    I gave you the most suitable answer on your own thread yesterday
    Re: How to Generating Excel workbook with multiple worksheets

  • How can i sync ipad1/iphone4 with itunes wirelessly using airport extreme network

    how can i sync ipad1/iphone4 with itunes wirelessly using airport extreme network

    Hi,
    This is currently not supported by iOS for any devices. Rumour is that iOS 5 will finally add this function, until then I'm afraid you are stuck with the good old cable.
    Jamie

  • How can I  get System dates  with time scheduler using threads

    how can I get System dates with time scheduler using threads.is there any idea to update Date in my application along with system Date automatic updation...

    What the heck are you talking about and whatr has it to do with threads?
    Current time: System.currentTimeMillis. Date instances are not supposed to be updated.

  • I have a Mac Laptop and want to buy an iphone.  Can I sync my iphone with my laptop using outlook 2010

    I have a Macbook about 2 years old.  Want to get an Iphone.  Can I sync the iphone with the Macbook using Outlook 2010. 

    See this previous discussion:
    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • Help with RSA Encryption using SATSA

    Hello,
    I am a new to writing code on J2ME . I am trying to encrypt data using
    RSA public key on J2ME using SATSA.
    I generated the public key using openssl in the PEM format and stored the
    key (mypublickey) as a Base64 decoded byte array in my code.
    Next, I did the following:
    X509EncodedKeySpec test - new X509EncodedKeySpec(mypublickey);
    KeyFactory kf = KeyFactory.getInstance("RSA");
    PublicKey key = kf.generatePublic(test);
    I used this key to encrypt as follows:
    cipher c = Cipher.getInstance("RSA");
    c.init(Cipher.ENCRYPT_MODE, key);
    c.doFinal(data,0,data.length,ciphertext,0);
    where byte[] data = "1234567890".getBytes();
    I get no errors during this process.
    Now, when I try to decrypt the string, I get a padding error as follows:
    javax.crypto.BadPaddingException: Data must start with zero
    The decode is done on a server.
    I tried getting an instance of the cipher with RSA/ECB/NoPadding and this time the decrypt gives junk.
    Question 2: The SATSA example online at http://java.sun.com/j2me/docs/satsa-dg/AppD.html
    has a public key embedded as a byte array. They haven't explained how
    this key is generated. Does someone know?
    Question 3: Suppose, I can get the modulus and exponent of the public key is there any way I can convert it to X509EncodedKeySpec so that I can
    use the APIs in SATSA?
    Thanks in advance for your help. I have been trying to solve this for a lot of time and any help will be greatly appreciated.

    Just wanted to add my code:
    public class test2 {
         public static void main(String[] args) throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, ShortBufferException {
              // TODO Auto-generated method stub
              byte [] data = "012345678901234567890123456789ab".getBytes();
              Base64 base64 = new Base64();
    /*public key generated by
              byte [] mypublickey = base64.decode("publickey in PEM format");
              byte [] ciphertext = new byte[128];
              X509EncodedKeySpec test = new X509EncodedKeySpec(mypublickey);
              byte [] myprivatekey = base64.decode("privatekey in pkcs8format");
    KeyFactory rsakeyfac = KeyFactory.getInstance("RSA");
              PublicKey pubkey = rsakeyfac.generatePublic(test);
              Cipher c1 = Cipher.getInstance("RSA");
              c1.init(Cipher.ENCRYPT_MODE, pubkey);
              c1.doFinal(data, 0,data.length, ciphertext);
              PKCS8EncodedKeySpec pks2 = new PKCS8EncodedKeySpec(myprivatekey);
              RSAPrivateCrtKey privkey = (RSAPrivateCrtKey)rsakeyfac.generatePrivate(pks2);
              Cipher c2 = Cipher.getInstance("RSA");
              c2.init(Cipher.DECRYPT_MODE, privkey);
              byte [] decrypteddata = c2.doFinal(ciphertext);
              System.out.println("Decrypted String is:"+new String(decrypteddata).trim());
    Error that I get is:
    Exception in thread "main" javax.crypto.BadPaddingException: Data must start with zero
         at sun.security.rsa.RSAPadding.unpadV15(Unknown Source)
         at sun.security.rsa.RSAPadding.unpad(Unknown Source)
         at com.sun.crypto.provider.RSACipher.a(DashoA13*..)
         at com.sun.crypto.provider.RSACipher.engineDoFinal(DashoA13*..)
         at javax.crypto.Cipher.doFinal(DashoA13*..)

  • How to encrypt byte array with out padding using RSA in Java?

    I've modulus and public exponent as byte[] array, so I'm trying to convert into BigIntegers and then create public key and then Cipher. Here is the example code:
    With this I'm always getting different encrypted bytes, is it because of padding. I dont want to use any padding so what parameter I need to pass along with RSA? I've modulus byte[] array size 64 bytes. I believe I'll get 64 encrypted bytes. I've content size of 32 bytes to be encrypted.
    --------code begin ---------------------------
    BigInteger bexponent = new BigInteger(pubExpo);
    BigInteger bmodulus = new BigInteger(modulus);
    KeyFactory keyFactory = KeyFactory.getInstance("RSA");
    RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(bmodulus, bexponent);
    RSAPublicKey pubKey = (RSAPublicKey)keyFactory.generatePublic(pubKeySpec);
    Cipher c = Cipher.getInstance("RSA");
    c.init(Cipher.ENCRYPT_MODE, pubKey);
    return c.doFinal(content);
    --------code end---------------------------

    With this I'm always getting different encrypted
    bytes, is it because of padding. Yes, if you're using PKCS1Padding (which is the default in SunJCE if you don't specify it). Have a look at the PKCS1 spec if you haven't seen it already.
    http://www.rsasecurity.com/rsalabs/pkcs
    Section 7.2.1 talks about type 2 padding, which uses random bytes as the PS string.
    I dont want to use
    any padding so what parameter I need to pass along
    with RSA? NOPADDING. You should be able to find this out by look at the "Supported Paddings" parameter in your provider's database. Which of course, means you'll need to supply the right number of bytes to the Cipher.

  • Owa_text.vc_arr: can't handle the string with more than 4000 characters?

    In the Oracel Web Application Server 4.0 documment, it says
    about owa_text.vc_arr :Type vc_arr is table of varchar2(32767)
    index by binary_integer.
    I amusing PL_SQL with Oracle8i and OWA4.0 web server.I want to
    use owa_text.vc_arr to pass the multple line texts in my form.
    If the text length is less than 4000 characters, everything works
    fine.However when the texts are longer than 4000 characters but
    less than the max length 32767 characters, I got this error
    message:
    OWS-05101: Execution failed due to Oracle error 2005
    ORA-02005: implicit (-1) length not valid for this bind or define
    datatype.
    Owa_text.vc_arr is supposed to handle the string with more
    than 4000 characters, is it true? Could anyone tell me why? Any
    help will be greatly appreciated!!!
    Thanks very much.
    Helena Wang
    Here is the pl_sql procedure to create my form:
    PROCEDURE myform
    IS
    BEGIN
    htp.p('
    <form action="'||service_path||'helena_test.saveform3"
    method=post>
    <input type=hidden name=tdescription value="X">
    Input1: <textarea name=tdescription rows=50 cols=70
    WRAP=physical></textarea>
    Input2: <textarea name=tdescription rows=50 cols=70
    WRAP=physical></textarea>
    <input type=submit name=WSave value="Save">
    </form>
    END;
    /***** here is the pl_sql procedure which I use to save the
    form***/
    procedure saveform3(tdescription in owa_text.vc_arr,
    WSave in varchar2 default 'No')
    is
    len pls_integer;
    begin
    for i in 2..tdescription.count loop
    len := length(tdescription(i));
    htp.p(len);
    htp.p(tdescription(i));
    end loop;
    end;

    Helena, I think you might get a better response either from the SQL-PL/SQL forum, or perhaps the Portal Applications forum - both of these tend to have folks very familiar with PL/SQL and the OWA packages.
    This forum is on Web services based on SOAP, WSDL and UDDI. These can be PL/SQL based but typically don't use the mod_psql or OWA web solution.
    As a pointer, I suspect you may already be familiar with, but just in case, you can always take a look at chapter 3 of the OAS documentation, "Developer's Guide: PL/SQL and ODBC Applications" where they go through a number of examples using parameters. See:
    http://technet.oracle.com/doc/appsrvr4082/guides/plsql.pdf
    Hope this or folks from the other list can help.
    Mike.

  • Can I Index a String with Quotes. How is Men's indexed

    HI!
    I want to know that when i index a column which has a string with quotes how is it indexed ie., if there is a string "men's" then how is this indexed? because i am not able to search for men's,and when i search as "men_s" nothing is returned how to do that?
    regards
    JD

    Use the printjoins lexer attribute -
    http://technet.oracle.com/doc/oracle8i_816/inter.816/a77063/cdatadi5.htm#35052

  • How could I Encrypt the data of SDO_GEOMETRY type using DBMS_CRYPTO package

    Hi:
    I want to Encrypt the data of SDO_GEOMETRY object type using DBMS_CRYPTO package.
    What could I do? hope anyone can help me,give me a suggestions!
    thanks in advance.
    lgs

    well, the spatial api would not be able to handle this data anymore, so what you are trying to do is converting an SDO_GEOMETRY to some cryptable user type (see http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_crypto.htm#sthref1506) and encrypting this.
    Before using the SDO_GEOMETRY type will have to decrypt and reconvert it again and pass it to the spatial query or function.

  • Can I sync my ipod with multiple computers using home share?

    Once I homeshare all my computers, can I sync my ipod with any of them?  Or do I always have to sync using the same computer.

    What kind of iPod do you have?
    For most iPods you can click Manually manage music on the summary page in iTunes. Check out Apple's document -> Using iPad or iPod with multiple computers.
    WTH.

  • Can a dotnet application talk with unix os using Oracle SOA Suit?

    how can a dotnet application talk with unix operating system using Oracle SOA Suite? I have to automate a process on unix server like create user through dotnet application.. is it possible?
    My dotnet application is used for creating users, granting access on the servers. Some servers are 21C servers and some are legacy servers. In this dotnet application a user make certain request for the rights on those servers e.g. create user, give access rights, change password. This application is treated as user interface and maintaining tool of all this information and later on the basis of that request it generates the job-sheet. This job sheet is forwarded to responsible engineer who further provisions the request manually by going to that specific server in the request. So I want to automate this process that when user put any access or create user request then the moment he puts the request, that request should be provisioned without any human intervention i.e. automatically users must be created or password must be changed. I believe you will get an enough idea about my problem from all above information. So please help me.

    Post your query at "SOA Suite Discussion Forum"
    SOA Suite

  • Can we patch Applications(ADPATCH) with no downtime using physical standby

    Hi ,
    As I know I can user Physical standby database for upgrade database with minimal downtime . Can I use the same with patching Oracle application using adpatch.
    In other words can we patch Application (using Adpatch) with no downtime using physical standby .
    Thanks in advance .
    Best Regards,

    In other words can we patch Application (using Adpatch) with no downtime using physical standby . No.
    Business Continuity for Oracle Applications Release 11i, Database Releases 9i and 10g [ID 216212.1] -- Section 4: Applying an Applications Patch
    Business Continuity for Oracle Applications Release 12 on Database Release 10gR2 - Single Instance and RAC [ID 452056.1] -- Procedure 4.4 - E-Business Suite Patch Application
    Business Continuity for Oracle E-Business Release 12 Using Oracle 11g Physical Standby Database [ID 1070033.1] -- Section 7: Oracle E-Business Suite Maintenance with Standby Database
    Thanks,
    Hussein

  • Can't sync my iPhone with my iMac using iCloud.

    I have installed Lion (10.7.3) on my iMac.  I have attempted to enable iCloud on my iMac, my iPhone (4S), and new iPad.  I am unable to sync my iMac with my iPhone or my new iPad.  I am able to sync my iPhone with my iPad and vice versa via iCloud.

    you pick one mac, and stick with it.
    when using multiple computers you will be asked if you want to erase because the iphone is meant to be used with one library.

Maybe you are looking for

  • How to add a column that shows the difference of two metrics columns?

    I created a pivot table with two metrics columns. One metrics column has the aggregation rule of 'Min', the other has 'Max'. Now I want to add a column to show the difference of these two metrics for each row. Is this possible? How to do it? Thank yo

  • AIronet 1300 password and user name recovery

    hello all i have a cisco aironet 1300..unfurtunately i cannot access because i forgot the password and username.. how do we recover the username and password without affecting the commands encoded in the device ?? thanks

  • Transferring from MacBook Pro to iMac

    I'm thinking about purchasing an iMac, currently I have a MacBook Pro. I don't want to get rid of my MacBook Pro, but I want to transfer everything over to the iMac since it has way more storage space and use that primarily at home and use my MacBook

  • Where to configure database schema detail in Oracle forms?

    Hi, i'm new to Oracle Application Server. Our version is 9.0.4. I have been searching on and no idea which file that stored the reference to the external customer database schema (not the infra repository database) that will be used in a form. Is it

  • CRM Middleware - Additional fields

    We are performing an initial load of Customer Master from R/3 to CRM and would like to include two new fields maintained in AUSP (characteristics table) in the download. I understand that we would be using the business object CUSTOMER_MAIN. Does anyo