Problem with the part decryption dbms_crypto

Hi all

I have a requirement for encryption, decryption of password... with a special key.

So first of all a key is passed to a function MAIN_KEY that is encrypted and the encrypted key will be passed to the function of encryption where the password will be encrypted with the special key.

next part of decryption, decryption function has to decrypt the supplied password, using the special key given earlier, but the code does not work as expected.

Special key encryption and normal encryption works well.

But the decryption function does not work.

Can someone help me solve the problem?

Code below:

<code>
create or replace
PACKAGE  passwd_enc_dec 
as
                    
  FUNCTION main_key(p_key              in varchar2) RETURN RAW DETERMINISTIC;
                     encryption_type    pls_integer;
                     ENCRYPTION_KEY     RAW (32);
  FUNCTION encrypt (p_plainText VARCHAR2) RETURN RAW DETERMINISTIC;
  FUNCTION decrypt (p_encryptedText RAW) RETURN VARCHAR2 DETERMINISTIC;
END;
/
create or replace
package body  test
as
                    
  encryption_key     raw (32);
FUNCTION MAIN_KEY(P_KEY IN VARCHAR2) RETURN RAW DETERMINISTIC IS 
 encryption_key  raw(2000);
 encryption_type    pls_integer;
begin
  encryption_type := dbms_crypto.encrypt_des
                   + dbms_crypto.chain_cbc
                   + dbms_crypto.pad_pkcs5;
  ENCRYPTION_KEY      := UTL_RAW.CAST_TO_RAW(P_KEY);
  return ENCRYPTION_KEY;
EXCEPTION
  WHEN OTHERS THEN NULL;
  END MAIN_KEY;
  
FUNCTION ENCRYPT (P_PLAINTEXT VARCHAR2) RETURN RAW DETERMINISTIC IS
  encrypted_raw      raw (2000);
  crypto_key raw(2000);
  
begin
  crypto_key := main_key(p_plaintext);
  encrypted_raw := dbms_crypto.encrypt (
                     src => utl_raw.cast_to_raw (p_plaintext),
                     TYP => ENCRYPTION_TYPE,
                     KEY =>crypto_key);
  RETURN ENCRYPTED_RAW;
  
EXCEPTION
  when others then return encrypted_raw;
  end encrypt;


function decrypt (p_encryptedtext raw) return varchar2 deterministic is
  decrypted_raw      raw (2000);
  dummy varchar2(1000);
  decrypto_key raw(2000);
begin
  decrypto_key := main_key(p_encryptedtext);
  decrypted_raw := dbms_crypto.decrypt (
                     src => p_encryptedtext,
                     typ => encryption_type,
                     key => decrypto_key );
  return (utl_raw.cast_to_varchar2 (decrypted_raw));
exception
  
  when others then 
  dummy := sqlerrm;
  return (utl_raw.cast_to_varchar2 (decrypted_raw));
end decrypt;
end;

Your encryption done original key but your decryption is not. So what you have to do is to use a key setting more in both encrypt and decrypt function. Try the below

create or replace

PACKAGE passwd_enc_dec

as

FUNCTION main_key(p_key VARCHAR2) RETURN GROSS precautions DETERMINISTIC;

FUNCTION fn_ENCRYPT (p_plainText VARCHAR2, VARCHAR2 p_key) RETURN RAW DETERMINISTIC;

FUNCTION fn_decrypt (p_encryptedText p_key RAW, VARCHAR2) RETURN VARCHAR2 DETERMINISTIC;

END;

/

create or replace

passwd_enc_dec package body

as

encryption_type PLS_INTEGER: = DBMS_CRYPTO. ENCRYPT_DES

+ DBMS_CRYPTO. CHAIN_CBC

+ DBMS_CRYPTO. PAD_PKCS5;

FUNCTION MAIN_KEY(P_KEY IN VARCHAR2) RETURN GROSS IS DETERMINISTIC

encryption_key RAW (32);

Start

encryption_key: = UTL_RAW. CAST_TO_RAW (P_KEY);

RETURN encryption_key;

END MAIN_KEY;

FUNCTION fn_ENCRYPT (P_PLAINTEXT VARCHAR2,

P_KEY VARCHAR2) RETURN GROSS IS DETERMINISTIC

encrypted_raw RAW (2000);

crypto_key RAW (32);

Start

crypto_key: = main_key (P_KEY);

encrypted_raw: = dbms_crypto.encrypt)

SRC-utl_raw.cast_to_raw (p_plaintext) online,

TYP-online encryption_type,

KEY-online crypto_key);

RETURN ENCRYPTED_RAW;

end;

function fn_decrypt (p_encryptedtext, RAW,

P_KEY VARCHAR2) RETURN VARCHAR2 DETERMINISTIC IS

decrypted_raw RAW (2000);

VARCHAR2 (1000) dummy;

decrypto_key RAW (32);

Start

decrypto_key: = main_key (P_KEY);

decrypted_raw: = dbms_crypto.decrypt)

CBC-online p_encryptedtext,

Typ-online encryption_type,

key-online decrypto_key);

Return (utl_raw.cast_to_varchar2 (decrypted_raw)) End Function

end;

end;

/

Tags: Database

Similar Questions

  • Problems with the part of the family.

    Tried to add children to the family. Someone was having trouble validating their credit or debit card?

    Teenwolf77 wrote:

    Tried to add children to the family. Someone was having trouble validating their credit or debit card?

    When you add a child to the family sharing, you must use a credit card.

    You can change it later to a debit card, but the credit card is a legal requirement at the time of registration.

  • There seems to be a problem with the soft ware.  We use the CS6 for Records services and when we try to save the record, part of the record is stored. The record to be saved as an mp3 file is 70 to 100 KB but recently only 3 KB are generally

    There seems to be a problem with the software.  We use the CS6 for Records services and when we try to save the record, part of the record is stored.  Usually the recording to be saved as an mp3 file is 70 to 100 KB but recently only 3 KB are recorded.  What should I do to fix this?

    You may need to reset your preferences of hearing files stored in C:\Users\"username"\AppData\Roaming\Adobe\Audition\5.0. If you rename this folder in 5.0.bak that hearing won't find it when you open the next time if it will recreate a new settings with the default settings folder. See if hearing then works as expected.

  • I have a problem with the download of Indesign CS 6 part 1 (Mac), it always stop at 6.8 MB download!

    As the title said, I have a problem with the download of Indesign CS 6 part 1 (Mac), it always stop at 6.8 MB download (about 1.2 GB). I tried to restart my mac, using the different browser but it's always the same result... Any help?

    Try this site

    Download Adobe CS6 Trials: Direct links (without Assistant or Manager) | ProDesignTools

  • Hi, I have a problem with the import of the 4000 SJCAM MOV files. MOV files are in formats supported for Adobe Premiere elements 11. But if I am importing of MOV file, only audio part is imported, part video is not imported. How can I solve this problem?

    Hi, I have a problem with the import of the 4000 SJCAM MOV files. MOV files are in formats supported for Adobe Premiere elements 11. But if I am importing of MOV file, only audio part is imported, part video is not imported. How can I solve this problem?

    haben

    Looking at the specs of your camera (SJCam 4000), we already know what video compression your camera uses. It is H.264.

    A H.264.mov file should be accompanied by a first elements 11. On what computer operating system is your first items 11 running?

    You have the latest version of QuickTime installed on your computer? And, you use QuickTime and first of 11 elements of a

    Account user with administrative privileges? Please go to Premiere elements 11 publish + share/computer/QuickTime to confirm that you will find

    presets it to the choice of QuickTime, it.

    What are the properties of these files H.264.mov - is it 1080 p (1920 x 1080 p 30) 30 or something else? Do you know if this device is registering with a variable or

    a constant rate?

    Please check and review and then we'll decide what next.

    Thank you.

    RTA

  • Anyone having problems with the new iPhone LTE connection 7 on Verizon?

    I am now on my iPhone second 7 with Verizon. I had four phones for me and my family. I have now had issues where I have no signal in the same areas where my signal allows to be strong. I can't solve the problem with the activation/deactivation of the airplane and then mode again in normal mode. My phone will rest with no signal for 5 minutes, then going to LTE with three bars. I also had the problem where I had only 1 x signal, while my son standing right next to me has LTE. And he had the same questions, where I'm on LTE and it gets no signal. I use to have LTE where I live and work all the time, now it's spotty at best. Apple has replaced me and my sons iPhones but not luck. Still do. Any ideas or an any other suffering?

    (1) go to settings/cell phone/cellular data Options/enable LTE and select ONLY the DATA. This seems to solve the problem (as a temporary solution) for most of the people affected by this problem. The bad part is your request might not be as clear (since they cannot use the highest LTE signals) and you can make calls and data at the same time. But it does not solve the issue.

    (2) there are rumors (but you didn't hear that from me that we only are not supposed to discuss beta software program Apple in this forum) that the new version of Apple Beta for iOS (which also includes an update of the software carrier Verizon to 26.0) seems to solve this problem. So, there's a light at the end of the tunnel.

  • Siri does not (problems with the connection)

    Hello

    I installed macOS Sierra yesterday. Everything seems to work fine, except Siri. With Siri I always get an error message "I am having some problems with the connection. Please try again in a moment. ». But this seems to appear every time. The network connection works fine, I can't access the Internet without problem.

    No idea how solve the problem?

    I use an iMac (27 inch, mid-2011). Internal microphone is connected, I also see the 'waves' change while I am speaking.

    Concerning

    Thomas

    Hey, thochstrasser. Thank you for using communities of Apple Support.

    It seems that Siri is reluctant to make his debut on your iMac after upgrade to Mac OS Sierra. I want to make sure that you get the benefit of this new feature on a Mac.

    1 try safe mode if your Mac does not start -even if your iMac to market, safe mode makes sure it starts successfully.

    2. How to test a question in an another user account on your Mac - since this is most likely a software problem, test to another user will indicate if it is right to your user account or throughout your system.

    3. use Time Machine to back up or restore your Mac - if it seems to be systemic, the next step should not cause problems. But it is always better "to have" a backup to the "need".

    4. on OS X Recovery - the issue as part of the operating system, reinstall should do.

    Have a great weekend!

  • Problem with the iPad using kindle app.

    WE have 2 iPads, iPad 3 and the air of aniPad. Nor are working using the kindle App freezes and looks like he's trying to download or open a book. Which of the two in the lower part shows also cloud and who is on the side of the unit?

    Amazon made the kindle app, not Apple.

    If you have problems with the app-contact Amazon Kindle.

    http://www.Amazon.com/GP/help/customer/display.html?nodeID=200298460

  • Satellite A660 - message: WARNING: a problem with the cooling system

    My laptop recenly started giving the error "Warning: a problem with the cooling system has been detected." Please turn off computer immediately and return it for service"- Yes the fan had stopped working and touchpad area was hot.

    So I take it on the type of service (toshiba) and must answer for fan, Mo, HARD drive, he said. Is this possible? -J' I have extended warranty, but is ' t it much? not to mention that it takes a month to get things down.

    He also mentioned that I could use the machine with a cooling pad until then if I wish.

    Any feed back?

    > Yes the fan had stopped working and touchpad area was hot.

    In this case, there is really a hardware problem.
    But I m wondering why he should replace the HARD drive and the motherboard
    Perhaps only the cooling module began at malfunction of course this is just a speculation
    If the technician has checked the material, then they need to know what parts are not OK.
    So don t think you have no choice.

    But the guarantee is valid for all is free

  • Problem with the new installation of Windows XP on the Satellite A100-259

    Hi all!

    I have a problem with the fresh install WIN XP on Satellite A100-259 (PSAA2E).
    I already deleted the partition, formatted (NTFS) and tried to reinstall from recovery disk that initially provided with the laptop. But whenever I try to install a problem is detected (for the most part it's 'page in the nonpaged area failure').

    I also tried to install the OS directly from MS Windows XP Home Edition SP2 CD - the same problem.
    I checked the partition using PQ Magic and discovered that there are ' partition table error #110 ".» So, what I did:

    (1) delete partition-> create new partition-> format (NTFS)-> reinstall from recovery disk-> has not yet;
    (2) partition delete-> install WinXP CD original by create and format partition option-> has not yet;
    (3) delete the partition (using the magic of pq)-> create partition (using the magic of pq)-> format NTFS partition for win xp option-> check partition-OK no problems don't-> installation of original win XP CD-installation without changes-> option failed even once
    (4) delete the partition (pq magic)-> create partition (pq magic)-> format NTFS partition for win xp option-> check partition-OK, no problem-> installation of the recovery disc-> has not yet

    Whenever a different error is detected, so I can't identify the problem. I don't know what to do. Does anyone have any ideas?

    Hello

    Seems that there are some problems with the standards of the partitions.
    A friend of mine has tried to install the OS on the recovery CD on the laptop that has been formatted with Partitions Magic 8 and the installation failed.
    It was very strange

    Finally, we have formatted the whole HARD drive using the CD original Windows XP Pro.
    We did not remove the partition but simply kicked this CD and after the configuration process spent, we formatted the whole HARD disk and install XP without creating all the partitions.

  • Qosmio G20 error message: problem with the cooling system has been detected

    I'm trying to fix a Qosmio G20 (which is about 3 years old, it is no longer in warranty).

    Error message: Warning: a problem with the cooling system has been detected.

    I managed to remove the outer case and observe the operation of the machine, and basically one of the fans does not at all. The fan which is closest to the power connector seems to work very well (he seems to be turning a lot, do not know if this is normal), but the other fan who does not seem to move at all.

    When I put in place the case and on the machine, I noticed after a few minutes the vent of the fan working heat sink had warm enough, while led the non-working fan remained cool.

    I cleaned the fan from dust and have also changed the BIOS battery mode mode high performance, but the problem still exists.

    I would be grateful if someone could give advice if the problem is the fan or something else.

    If the fan is the problem, where I can buy a: i live in the United Kingdom?

    Hello

    I think there might be something wrong with the cooling module and the replacement would be necessary.
    Usually, this should be done by an authorized provider (ASP) in your country.

    Technicians could replace it with a new part and also could renew the thermal grease which is placed between the module and the CPU cooling.

    So contact the ASP in your country and ask for later handling.

    By the way; also, you can buy the cooling of the ASP module!

    Good luck

  • Satellite U400 - 10L: problem with the start-up & reboot

    Hello

    Well I don't like much about the touchpad overheating but I have a problem. When I restart this mobo instead of activate after a reboot it stays black without any reaction only lower diods, dvd - rom and the display flashes (can't hear fan or hard drive).

    If I press the power button / stop all the icons of diod (ac, pwr, hdd bat) shine up just for a second and new (can't hear the fan hard drive or cpu) computer does not turn on. All this happened only when AC cable is connected to the power if I use just notebook power source battery boots and restart without problems.

    If I remove battery completely from the laptop, once more, I get the same symptoms (cannot start). And the saddest part of this story is the fact that I got brand new Toshiba U400 10 L to the seller and got a new.
    It has the exact same problem.
    As you all probably understand im crazy because in the last two days, I tried really everything, including the BIOS without flashing and the success.

    Well im not sure whats going on, but this could be the problem with the battery or a bad contact?
    Any ideas?
    I would return it back?

    Thanks much for the reply

    Hello

    The behavior of your laptop is really strange and I suppose it might be bound only to a hardware problem.

    A friend of mine couldn't t start the laptop connected to the AC adapter the power adapter is faulty. It was only possible to start Notepad using the battery, and only if the battery was not completely empty.

    I put t know if your AC adapter failures but the authorized service provider should definitely check out the laptop and accessory for laptop (AC adapter).

    Then call the ASP in your country and ask the technicians for later handling.

    Greetings

  • Equium L10: Problem with the main battery and battery RTC

    Hello

    I have the Toshiba Equium L10 and it is about 14 months old and I have problems with the battery and how much time it takes after a full charge. I also have problems with the RTC battery and an ERROR 0271: check date and time settings message when I turn on the laptop.

    Regarding the battery, I can fully charge it upward in about 3 hours, but when I start to use it, apparently in the last few hours around one and a half or so and then it needs to be recharged. I can have down for about 40 minutes and then turn it off and come back later or in a day or two. How long should I expect from a fully charged battery?

    About the batttery RTC, it really becomes a pain and I only started to get the message of the ERROR 0271 start-up, in recent weeks. I can charge the battery pack and then leave for a few days, but when I turn it on, I get the message ERROR 0271 on the date and time incorrect. Surely after a full charge, the RTC battery should last longer than a few days?

    The manual says that if the RTC battery is exhausted or becomes weak, you must charge the battery of the CCF for 24 hours, in a different part of this manual indicates between 24 and 48 hours, but how can load you for long when the sections concerning the charging battery pack status after charging the battery you unplug the power adapter because leaving connected will shorten the life expectancy of the Battery Pack. So, how we can charge the battery of the CCF for 24 to 48 hours if we shouldn't leave the AC adapter plugged in once the battery is charged - which is nearly three hours. Suggestions about these problems would be appreciated.

    Besides we all know that it is easy to change the CMOS/RTC battery in your desktop base unit, but is it easy to change in a Toshiba Equium L10?

    Concerning

    Brave0

    Hi Brave0,

    The normal recommendation for the CMOS (RTC) battery is to leave the laptop connected to the power supply at least 12 hours when the main battery is fully charged. The charging circuit is going to hijack the current to the load automatically RTC battery and no current will be forwarded to your main battery.

    Recommendation do not leave the power adapter is plugged in the main battery is fully charged is really only applicable to older laptops that used no batteries Li - ion and therefore they had to be completely discharged before recharging to avoid any effect 'memory' of the battery.

    With modern Li-ion batteries, it is quite safe to leave the battery when fully charged and still power the laptop from the AC adapter. The charging circuit will pass all the battery charge if it is fully charged.

    Kind regards

  • Problem with the digital signatures of workers govt

    If I get emails quite frequently NAVAIRSYSCOM workers via my e-mail from work which is the right company, no Government excuseraient. On my last phone an orginal Droid, a few emaisl would tell me there was a problem with the digital signature for e-mails, but I always saw the e-mail itself.

    Since switching to the Maxx HD, I can see no longer the body of emaisl to these people. All I get is a "impossible to decrypt this message." It is not every person govt, but enough that it is very frustrating. Any ideas on how to work around this problem? and I know that the message is not encrypted, I can see fine by Exchange and we are app.

    We have a couple of our team focuses on similar issues. Passing this along.

  • Problem with the report and the system of axis 2d

    Hi, I'm trying to write a script with tiara, who wrote a 2d axis system in the report but I'm having a lot of problems with it.

    What I'm trying to do, is make 3 or more system axis 2d in the report, each displaying a part of the data of 2 channels (x = ch0, ch1 = y).

    With only 1 graphic I get what I want, but when I try to add the 2nd or the 3rd, they show without my defined x-scale and with the offset x different from the first chart.

    I tried everything, but I could not remedy

    I added as attachments the .csv file that I use to ch0 and ch1 and 2 screen shoots "what I get" (about the problem with the script) and "what I hope to get" (done manually, is what I'm trying to get the report)

    Any help will be appreciated, thanks in advance

    Ierman

    I'll post my code here:

    Dim Xscale, Yscale
    XScale = Array (0,25,0,5,49)
    Yscale = Array(-0.2,0.2,-0.2,10,4)
     
    Call PicDelete()
    Call GraphObjNew ("2D-Axis", "2DAxis1")
    Call GRAPHObjOpen ("2DAxis1")
    D2AxisTop = 1

    D2AxisBottom = 70
    D2AxisLeft = 1
    D2AxisRight = 1
    Call GRAPHObjOpen ("2DYAxis1_1")
    D2AxisyScaleType = "manual".
    D2AXISYBEGIN = Yscale (0)
    D2AXISYEND = Yscale (1)
    D2AXISYORIGIN = Yscale (2)
    D2AXISYTICK = Yscale (3)
    D2AXISYMINITICK = Yscale (4)
    Call GRAPHObjClose ("2DYAxis1_1")
    Call GRAPHObjOpen ("2DXAxis1_1")
    D2AxisxScaleType = "manual".
    D2AXISXBEGIN = Xscale (0)
    D2AXISXEND = Xscale (1)
    D2AXISXORIGIN = Xscale (2)
    D2AXISXTICK = Xscale (3)
    D2AXISXMINITICK = Xscale (4)
    D2AxisXTxt = ""

    D2AxisXColor = 'black '.

    D2AxisXTickAuto = 1
    D2MTickLineWidth (1) = 0.1
    D2MTickLineType (1) = "solid".
    D2AxisXTickSize = 60
    D2AxisXTxtAutoCo = 0
    D2MTickColor = "red".
    Call GRAPHObjClose ("2DXAxis1_1")
    Call GraphObjNew("2D-Curve","New_Curve")

    Call GraphObjOpen ("New_Curve")

    D2CCHNX = "[1] / [1]" "

    D2CCHNY = "[1] / [2]" "

    D2CurveColor = "red".
    Call GraphObjClose ("New_Curve")
    Call GRAPHObjClose ("2DAxis1")

    Dim Xscale1, Yscale1
    Xscale1 = Array (25,50,0,5,49)
    Yscale1 = Array(-0.2,0.2,-0.2,10,4)
    Call GraphObjNew ("2D-Axis", "grafic")
    Call GRAPHObjOpen ("grafic")
    D2AxisTop = 40

    D2AxisBottom = 37
    D2AxisLeft = 1
    D2AxisRight = 1
    Call GRAPHObjOpen ("2DYAxis1_2")
    D2AxisyScaleType = "manual".
    D2AXISYBEGIN = Yscale1 (0)
    D2AXISYEND = Yscale1 (1)
    D2AXISYORIGIN = Yscale1 (2)
    D2AXISYTICK = Yscale1 (3)
    D2AXISYMINITICK = Yscale1 (4)
    D2AxisYTxt = "" ' testo asse label y
    Call GRAPHObjClose ("2DYAxis1_2")
    Call GRAPHObjOpen ("2DXAxis1_2")
    D2AxisxScaleType = "manual".
    D2AXISXBEGIN = Xscale1 (0)
    D2AXISXEND = Xscale1 (1)
    D2AXISXORIGIN = Xscale1 (2)
    D2AXISXTICK = Xscale1 (3)
    D2AXISXMINITICK = Xscale1 (4)
    D2AxisXTxt = «»

    D2AxisXColor = 'black '.

    D2AxisXTickAuto = 1
    D2MTickLineWidth (1) = 0.1
    D2MTickLineType (1) = "solid".
    D2AxisXTickSize = 60
    D2AxisXTxtAutoCo = 0
    D2MTickColor = "red".
    Call GRAPHObjClose ("2DXAxis1_2")
    Call GraphObjNew("2D-Curve","New_Curve1")

    Call GraphObjOpen ("New_Curve1")

    D2CCHNX = "[1] / [1]" "

    D2CCHNY = "[1] / [2]" "

    D2CurveColor = "red".
    Call GraphObjClose ("New_Curve1")
    Call GRAPHObjClose ("grafic")

    Hi lerman,.

    Here is an edited version of your code that works on my computer.  A problem that I know that I fixed it was that your presentation of the STATE was in the name-oriented mode but you use the variables based on the number to assign it X and Y channels.  The execution of these commands in a loop FOR makes it much easier to debug the code and to avoid any annoyance at first.

    Brad Turpin
    Tiara Product Support Engineer

    National Instruments

Maybe you are looking for

  • Empty project files when no message is visible

    Now a day, I receive this error message: "there was an error saving message in drafts. Try again? »All my Drafts folders are empty and I used the compact and repair function on them also. Not finding anything here, I did a Google search and found an

  • Satellite L450D - reset in the factory installation

    Hi guys, tried a factory reset and the laptop turned off itself to half way through, and I can't return it to all the. The laptop is a Toshiba Satellite L450D-11w and it was under windows 7. When I try to load it up I get the message bootmgr lack pre

  • Skype cannot connect over 3g but connects over wifi

    I recently had problems on my galaxy tab 2 every time I want to log in to Skype on 3 g network. It never connects, but it works well when am on wifi network. AV checked all the limitations of parameters and the data, but nothing seems to work. Someon

  • Satellite P500-15E does not work anymore

    Hello, I have a big problem here. My laptop just crashed, and it no longer works. I think it could be the motherboard that has overheated, because I did all the tests that I could. I know a computer to function without graphics card, ram etc... (at l

  • missing drivers Windows 8.1 dv6t - b 6, 00 Quad edition

    I reformatted in Windows 8.1 on my dv6t - b 6, 00 Quad Edition and updated for most drivers, but it still lacks some functionality. Although I have installed the driver for my fingerprint reader, and it is listed in my device manager, I'm unable to i