Encrypt and decrypt using the key of the table

Dear Experts,

Here is my package to encrypt and decrypt with triples in oracle 11 g.

In my package, I used encryption_key (3FECCDC7D348A85B096F0B43C4C6A38DBBD369DB37FEA435) according to this key we are encryption and decryption.

My requirement is now, I don't want to spend the encryption_key in my code.we key stored in a table (key_details) and using the key column, we her encrypt and decrypt the data.

-----------------------------------

create the table key_details

(

Identification number,

VARCHAR2 (48) key

);

insert into key_details values(1,'3FECCDC7D348A85B096F0B43C4C6A38DBBD369DB37FEA435');

-------------------------------------

CREATE or REPLACE PACKAGE encr_decr

AS

FUNCTION encrypt (p_plainText VARCHAR2) RETURN RAW DETERMINISTIC;

FUNCTION decrypt (p_encryptedText RAW) RETURN VARCHAR2 DETERMINISTIC;

END;

/

CREATE or REPLACE PACKAGE encr_decr BODY

AS

encryption_type PLS_INTEGER: = DBMS_CRYPTO. ENCRYPT_3DES

+ DBMS_CRYPTO. CHAIN_ECB

+ DBMS_CRYPTO. PAD_PKCS5;

encryption_key RAW (48): = UTL_RAW.cast_to_raw ('3FECCDC7D348A85B096F0B43C4C6A38DBBD369DB37FEA435');

FUNCTION encrypt (p_plainText VARCHAR2) RETURN RAW DETERMINISTIC

IS

encrypted_raw RAW (2000);

BEGIN

encrypted_raw: = DBMS_CRYPTO. ENCRYPT

(

SRC = > UTL_RAW. CAST_TO_RAW (p_plainText),

Typ = > encryption_type,.

key = > encryption_key

);

RETURN encrypted_raw;

END encrypt;

FUNCTION decrypt (p_encryptedText RAW) RETURN VARCHAR2 DETERMINISTIC

IS

decrypted_raw RAW (2000);

BEGIN

decrypted_raw: = DBMS_CRYPTO. DECRYPT

(

SRC = > p_encryptedText,

Typ = > encryption_type,.

key = > encryption_key

);

RETURN (UTL_RAW. CAST_TO_VARCHAR2 (decrypted_raw));

END decrypt;

END;

/

Help, please.

create or replace package body encr_decr

as

encryption_type pls_integer: = dbms_crypto.encrypt_3des

+ dbms_crypto.chain_ecb

+ dbms_crypto.pad_pkcs5;

gross encryption_key (48);

--

function encrypt (p_plaintext varchar2)

gross return deterministic

is

Start

Return dbms_crypto.encrypt (CBC-online utl_i18n.string_to_raw (p_plaintext)

typ-online encryption_type

key-online encryption_key

);

end encrypt;

--

function decrypt (gross p_encryptedtext) return varchar2 deterministic

is

Start

Return utl_i18n.raw_to_char (dbms_crypto.decrypt (src-online p_encryptedtext

typ-online encryption_type

key-online encryption_key

)

);

put an end to decrypt;

Start

Select the key in encryption_key

of key_details

where id = 1;

end;

/

Tags: Database

Similar Questions

  • Who holds the keys for encryption AES mentioned in the table under "security and features iCloud?

    Who holds the keys for encryption AES mentioned in the table under "security and features iCloud?

    Article

    Security and privacy - Apple Support Overview iCloud

    has a useful table in the section entitled Security and features iCloud.

    The table shows the types of keys used to secure the different types of data.

    Apple holds these keys as it may be requested of Apple by third parties?

    Hmmm... You definitely raise a good and valid question to which I don't know the answer to, but if I had to guess, I would say that no one.  Would this be possible?  I know I've heard Cook mention that they "don't hold the keys" but does the same thing, it refers?  It would make a very interesting topic of discussion.

  • Encrypt and decrypt the algorithm for visual basic 6

    I would like to know a code complex algorithm in Visual Basic 6 to encrypt and decrypt ini files to encrypt credentials

    Kindly help.

    Hello

    I suggest you to ask your question in the below link:

    http://social.msdn.Microsoft.com/forums/en-us/category/VisualStudio, vslanguages, vstfs, netdevelopment, vsarch

  • Can I use a disk Windows 7 Home full version and just use the key to version upgrade license?

    Original title: the reconstruction of my PC - Windows 7 issue.

    I will be rebuilding my PC which has Windows 7 Home 64 bit installed.  I did the upgrade from Vista to Windows 7 with a family 3-pack.  Can I use a disk Windows 7 Home full version and just use the key to version upgrade license?  Seems a little ridiculous that I have to install another OS and do the upgrade.  I searched the forums and could not easily find an answer to this question.  Help, please.  Thank you!

    Also note that as you change not the motherboard Windows should not require re-installation and activation.

    J W Stuart: http://www.pagestart.com

  • Use to encrypt and decrypt in Scenerio

    Hello
    I'm new to ODI Env.I just need to clarify a thing of ODI Scenerio is that what is the use of Encrypt and decrypt when we right click on the generated Scenrio recently? If I encrypt also I can able to run and remove the scenario and what ever.please suggest me and so I have can use this concept in my Production.

    Hello

    Encrypt a script/procedure/KM helps protect the valuable code.

    An encrypted script or KM or a procedure cannot be read or modified if it is not decrypted. Orders generated in the newspaper by a scenario Encrypted KM or procedure are unreadable.

    Oracle Data Integrator uses a personal encryption key-based encryption algorithm. This key can be saved in a file and reused to perform encryption or decryption operations.

    P.S:there is impossible to decipher a procedure without the encryption key or encrypted KM. Therefore, it is strongly recommended to keep this key in a safe place. It is also advisable to use a unique key for all developments.

    Thank you
    Guru

  • When you use the question mark, appears like a capital E with accent French and cannot use the quotes.

    Original title: I can't use my question mark (rises like a capital E with accent French and cannot use the quotes)

    I'm having a problem from time to time with my ability to use marks quotaion, brands etc. How can I treat it DEFINITIVELY the question.

    Thank you

    Hi golfnut11,

    1. you are using a laptop?

    2. you remember to make changes to the computer priro to this question?

    Step 1:

    If you use a laptop, check if the FN key is enabled. If so, then try to turn it off and check.

    Step 2:

    You can also try to check the keyboard on the screen and if the problem occurs or not.

    Check out the link:

    Type without using the keyboard (on-screen keyboard)

    http://Windows.Microsoft.com/en-us/Windows7/type-without-using-the-keyboard-on-screen-keyboard

    If you use a Microsoft keyboard, you can also consult the following article:

    Troubleshoot wired keyboards that do not or only the erroneous characters category
    http://support.Microsoft.com/kb/258826

    Hope this information is useful.

  • Inject an apple ID and PW using the Configurator 2?

    Hi all

    Wondering if a id apple & PW can be added to a profile and deployment using the Configurator 2. Sorry if this has been covered, am new to this and learning and discovery I.

    see you soon,

    Kristian.

    Hello, Kristian,.

    AC2 negates the need to have a configuration of account iTunes\AppleID on each device, can I ask why you wanted to do this, there may be a better way? ipads how are you trying to install? ipad users can add their own iTunes account to download other additional applications then deployed via the configurator.

    Kind regards

    Rick

  • Why my computer loses its cursor and/or loses its and must use the mouse to go back?

    I will be typing along and all of a sudden, nothing shows up on the screen and must use the mouse to get back.

    Also will be done solitare or another game and lose her and the mouse to move the things. Is this a virus?

    I updated my windows and nothing showed as a problem here.

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

  • I a s 6 more and when using the phone, if my face touches the screen it clicks on the logout button and the phone hangs up the call. Is it possible to prevent this without holding the phone away from my face when calling?

    I a s 6 more and when using the phone, if my face touches the screen it clicks on the logout button and the phone hangs up the call. Is it possible to prevent this without holding the phone away from my face when calling?

    iPhones have a proximity sensor which is supposed to automatically turn off the screen when you hold it in your face. If this is not the case you can take the phone and have it checked.

  • Re: Satellite L735 PSK0CE: WLan and BT use the same frequency

    Hello world

    I reinstalled my Toshiba Satellite L735 - PSK0CE with Windows 7, until the one and download all the drivers for it, I did not too Wirelles conection, Lan and the wirelless use the same channell radiofrecuency than Bluetooth

    Can you help me with this problem?

    Thanks in advance

    Post edited by: aku - aku

    Hello

    WiFi and BT use the same frequency. For the most part this isn't a big problem but in case you notice a few connection problems with WLan or BT, you must disable WLan using BT or must turn off BT if you want to use the WLan.

  • Can I use your Apple TV when I do not have a modem, and I use the Wifi in the hotel room?

    Can I use your Apple TV when I do not have a modem, and I use the Wifi in the hotel room?

    Thank you!

    Probably not, but depends on the hotels wifi access. most of the hotels that I stay in you will have to "login" via web browser and the ATV doesn't have access to any browser...

    your best bet would be to broadcast directly from a mobile device connected to the tv in your hotel via a HDMI adapter...

  • I installed a game for windows XP and then used the troubleshooting tool to convert so that I can play in 7.__it still doesn't react. What should I do? Please answer__

    I installed a game for windows XP and then used the troubleshooting tool to convert so that I can play at 7.
    It still fails. What should I do? Please answer

    Hello

    a. what game do you have installed?
    b. do you get errors trying to run the game in compatibility mode?

    Look for error messages in the event viewer. If you find error messages after return the exact error message so that we can help you better.

    Measures to check the application event log:

    1. click on start.
    2. in the search box type eventvwr.msc, and then on enter.
    3. now, click Application in the event viewer (local).
    4. now locate the event log on the right side of the event viewer window.

    http://Windows.Microsoft.com/en-us/Windows7/open-Event-Viewer 
    http://Windows.Microsoft.com/en-us/Windows7/what-information-appears-in-event-logs-Event-Viewer

    You can try to perform the clean boot on your computer and check if that helps.

    From your computer by using a minimal set of drivers and startup programs so that you can determine if a background program is interfering with your game or program. This type of boot is known as a "clean boot".

    To perform a clean boot on a computer, follow these steps.
    1. click on start, type msconfig in the search box and press ENTER.

    If you are prompted for an administrator password or a confirmation, type the password, or click on continue.

    2. in the general tab, click Selective startup.
    3. under Selective startup, clear the check box load startup items.
    4. click on the Services tab, select the hide all Microsoft Services check box, and then click Disable all.
    5. click on OK.
    6. When you are prompted, click on restart.
    7. after the computer starts, check if the problem is resolved.

    Please follow the system in the boot environment. If the problem does not occur, it indicates that the problem is related to an application or a service, we have disabled. You can use the MSCONFIG tool again to reactivate the disabled one by one element to find the culprit.

    If your issue is resolved, follow the how to determine what is causing the problem section in KB article to narrow down the exact source.
    For more information visit: http://support.microsoft.com/kb/331796

    After you determine the startup item or the service that is causing the problem, contact the manufacturer of the program to determine if the problem can be solved. Or, run the System Configuration utility, and then click to clear the check box of the element of the problem.

    To restore your computer to a Normal startup mode, follow these steps:

    1. click on start in the box start the search.
    2. type msconfig and press ENTER.

    If you are prompted for an administrator password or a confirmation, type the password, or provide confirmation.

    3. on the general tab, click Normal Startup - load all device drivers and services and then click OK.
    4. When prompted, click on restart.

    You can check its compatibility with windows 7 in the Compatibility Center.
    http://www.Microsoft.com/Windows/compatibility/Windows-7/en-us/default.aspx

    Hope this information is useful.

  • HTTP and without using the APN settings

    Hello

    Is there a way I can get my application, use internet using HTTP and without using the settings APN and GPRS for. Please note that this should work on both BES and BIS.

    Applications like Google maps and Facebook on Blackberry using internet, but,.

    -They do not need any APN settings

    -They don't need to be active GPRS BlackBerry

    Thanks in advance,

    Naveen

    You have a chance to go through this sticky thread.

    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&thread.ID=29103

  • I'm trying to connect two monitors and one using the hdmi port and the other vga. How can I get the pc to recognize the two?

    Original title: multiple monitors

    I'm trying to connect two monitors and one using the hdmi port and the other vga. How can I get the pc to recognize the two?

    Hi David,

    Thanks for posting your query on the Microsoft Community.

    I suggest you refer to the Microsoft Help Articles below and try the steps mentioned.

    Check out the link:

    http://Windows.Microsoft.com/en-in/Windows-8/how-connect-multiple-monitors#1TC=T1

    You can also check:

    http://Windows.Microsoft.com/en-in/Windows-8/get-best-display-monitor

    Hope this information helps. Please let us know if you need any other help with Windows in the future. We will be happy to help you.

  • I have a server/database Application Express 4.1.1 running and a server/database Application Express 4.2.0 running. Is it risky to try to upgrade to the latest version and start using the universal or complex theme?

    I have a server/database running Application Express 4.1.1 and a server/database active Application Express 4.2.0. Is it risky to try to upgrade them both to the latest version and start using the universal or complex theme?  Is how easy it to do? Recommended?

    The servers are windows 2008 r2. Don't know if it matters.

    I'm not exactly an expert at the express request...

    Hi DJake,

    DJake wrote:

    I have a server/database Application Express 4.1.1 running and a server/database Application Express 4.2.0 running. Is it risky to try to upgrade them both to the latest version and start using the universal or complex theme?  Is how easy it to do? Recommended?

    The servers are windows 2008 r2. Don't know if it matters.

    I'm not exactly an expert at the express request...

    Please read the documentation of the requirement for Oracle APEX 5. Ensure that your environment meets these requirements. Upgrade your oracle database or other software if necessary components and then you can go right 4.1/4.2 to 5.0 update according to the above-discussed upgrade strategies in the above discussions.

    Reference: https://docs.oracle.com/cd/E59726_01/install.50/e39144/pre_require.htm#HTMIG376

    You should go for upgrade of the Oracle APEX of 4.1 to 5.x. Regression test your applications to remove if any errors introduced by upgrade. The kickoff of a new project to migrate your applications to universal theme.

    Reference:

    Kind regards

    Kiran

Maybe you are looking for