Hash created using DBMS_CRYPTO.Hash and md5sum, sha1sum not maching.

Hi,
I have PL/SQL script MD5SH1.sql to generate md5 and sha1 hash, but hash generated by this script and
hash generated by md5sum and sha1sum utility not matching.
Pl. tell me what is wrong,
------------------MD5SH1.sql----------------
set serveroutput on
DECLARE
input_string VARCHAR2 (200) := 'Lord of the ring'';
output_str_md5 VARCHAR2 (200);
output_str_sh1 VARCHAR2 (200);
hash_raw_md5 RAW(2000);
hash_raw_sh1 RAW(2000);
hash_algo_type1 PLS_INTEGER := DBMS_CRYPTO.HASH_MD5;
hash_algo_type2 PLS_INTEGER := DBMS_CRYPTO.HASH_SH1;
BEGIN
DBMS_OUTPUT.PUT_LINE ( 'Original string: ' || input_string);
hash_raw_md5 := DBMS_CRYPTO.Hash
src => UTL_I18N.STRING_TO_RAW (input_string, NULL),
--src => input_string,
typ => hash_algo_type1
hash_raw_sh1 := DBMS_CRYPTO.Hash
src => UTL_I18N.STRING_TO_RAW (input_string, NULL),
--src => input_string,
typ => hash_algo_type2
output_str_md5 := UTL_I18N.RAW_TO_CHAR (hash_raw_md5,'US7ASCII');
output_str_sh1 := UTL_I18N.RAW_TO_CHAR (hash_raw_sh1,'US7ASCII');
--output_str_md5 := hash_raw_md5;
--output_str_sh1 := hash_raw_sh1;
--dbms_output.put_line(hash_raw_md5);
--dbms_output.put_line(rawtohex(hash_raw_sh1));
DBMS_OUTPUT.PUT_LINE ('MD5 Hash: ' || output_str_md5);
DBMS_OUTPUT.PUT_LINE ('SH1 Hash: ' || output_str_sh1);
END;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The O/p of this script is
SYS@mydb> @MD5SH1.sql
Original string: Lord of the ring
MD5 Hash: �����+.v�`�a_A
SH1 Hash:
����E�k�[�F[c�2�
PL/SQL procedure successfully completed.
SYS@mydb>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The o/p of md5sum and sha1sum is
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[san@sde4 ~]$ echo "Lord of the ring" |md5sum
f3fbb6dfd8a2d6f8f6aeabc4d6e17c57 -
[san@sde4 ~]$ echo "Lord of the ring" |sha1sum
856f6132e23c7e335ca4188bd45c7bc9515f6905 -
[san@sde4 ~]$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Why these 2 hashes are not matching?
-Santosh Mhaskar

You should take in account, that echo command adds a carriage return by default.
SQL> set serveroutput on
SQL> set echo on
SQL> declare
  2    input_string       varchar2(200) := 'Lord of the ring'||chr(10);
  3    output_str_md5  varchar2(200);
  4    output_str_sh1  varchar2(200);
  5    hash_raw_md5       raw(2000);
  6    hash_raw_sh1       raw(2000);
  7    hash_algo_type1 pls_integer := dbms_crypto.hash_md5;
  8    hash_algo_type2 pls_integer := dbms_crypto.hash_sh1;
  9
10  begin
11    dbms_output.put_line('Original string: ' || input_string);
12    hash_raw_md5      := dbms_crypto.hash(src => utl_raw.cast_to_raw(input_string),
13                                       typ => hash_algo_type1);
14    hash_raw_sh1      := dbms_crypto.hash(src => utl_raw.cast_to_raw(input_string),
15                                       typ => hash_algo_type2);
16    dbms_output.put_line('MD5 Hash: ' || lower(rawtohex(hash_raw_md5)));
17    dbms_output.put_line('SH1 Hash: ' || lower(rawtohex(hash_raw_sh1)));
18  end;
19  /
Original string: Lord of the ring
MD5 Hash: f3fbb6dfd8a2d6f8f6aeabc4d6e17c57
SH1 Hash: 856f6132e23c7e335ca4188bd45c7bc9515f6905
PL/SQL procedure successfully completed.
SQL> !echo "MD5 Hash:" `echo 'Lord of the ring' | md5sum`
MD5 Hash: f3fbb6dfd8a2d6f8f6aeabc4d6e17c57 -
SQL> !echo "SH1 Hash:" `echo 'Lord of the ring' | sha1sum`
SH1 Hash: 856f6132e23c7e335ca4188bd45c7bc9515f6905 -Best regards
Maxim

Similar Messages

  • Plugin created using C++ 6 and Acrobat 6 SDK Not Working in Windows

    I have an Acrobat plugin compiled in Visual C++ 6 using Acrobat 6 SDK. The plugin works flawlessly in Acrobat versions 6 to 9 in Windows XP. While the plugin is able to add a menu iterm and tool bar icon in Windows 7, it causes Acrobat to hang everytime when activated in which event I have to close Acrobat. Since Visual C++ 6 is a 32 bit app, I have to believe that Acrobat 6 SDK is responsible for the behavior described herein in attempting to get the plugin to work in Windows 7. Any comments or suggestions regarding what Visual C++ version to use along with the appropriate Acrobat SDK to get the plugin to work in Windows 7 are appreciated. In doing so, I would also be interested in knowing what backward compatibility one may expect w/regard to previous versions of Acrobat in updating the plugin to work in Windows 7. As for the answer, correct me if I am wrong but I'm thinking Acrobat 9.

    Adobe hasn't supported Acrobat 6, VC6 or the Acrobat 6 SDK for at least 5 years.  You will need to move to the Acrobat 9 SDK if you wish support.
    And Acrobat 9 and its SDK are fine with Windows 7.
    From: Adobe Forums <[email protected]<mailto:[email protected]>>
    Reply-To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>
    Date: Thu, 1 Dec 2011 01:15:42 -0800
    To: Leonard Rosenthol
    Subject: Re: Plugin created using C++ 6 and Acrobat 6 SDK Not Working in Windows Plugin created using C++ 6 and Acrobat 6 SDK Not Working in Windows
    Plugin created using C++ 6 and Acrobat 6 SDK Not Working in Windows
    created by gomfp49<http://forums.adobe.com/people/gomfp49> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4056529#4056529

  • HT4484 i used to have an app store and lost it and i created a new one and i can not update the iphoto app because it was updated with the old account, is there a solution for this problem?

    i used to have an app store and lost it and i created a new one and i can not update the iphoto app on my macbook pro because it was updated with the old account, is there a solution for this problem?

    Content and Apple IDs -
    Content is forever tied to the Apple ID that bought it. Apple does not transfer content from one Apple ID to another. Apple does not merge Apple IDs. You will never be able to access your content bought with one Apple ID with a new Apple ID.

  • I am using laptop hitting and slow system not working

    i am using laptop hitting and slow system not working and very late opan file browser every think . plez help me

    Hi,
    Shut down the notebook.  Tap away at the esc key as you start the notebook to enter the Start-up Menu.  Select the Bios option ( usually f10 ) and under the Advanced or Diagnostic tab you should find the facility to run tests on both the Hard Drive and Memory.  Post back with the details of any error messages.
    Note:  If the option to run these tests is not available in the Bios Menu, use the f2 diagnostic menu instead.
    Can you also post back with the following details.
    1.  The full Model No. and Product No. of your notebook - see Here for a guide on locating this information.
    2.  The full version of the operating system you are using ( ie Windows 7 64bit ).
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • I recently purchased a used ibook g4 and want to update to itunes 10.2. It tells me i need mac os 10.5 to do so. Today is the first day I have ever used a mac and I am not well versed on computers to begin with. What do I need to do?

    I recently purchased a used ibook g4 and i want to update to itunes 10.2. It tells me that I need to update to mac os 10.5.  Today is the fist time that I have ever used a mac and I am not very well versed on computers to begin with. From what I gather I need to purchase the mac os 10.5 but there are a lot of different options and I dont know what I need to do. Can somebody point me in the right direction?  I dont want to spend too much money because i just want my ipod touch to be compatible with my ibook. thank you

    Hi
    Your question is more suitable for the 10.4's General Forum rather than 10.4 OSX Server. Post here instead:
    https://discussions.apple.com/community/mac_os/mac_os_x_v10.4_tiger?categoryID=1 77
    You'll have more of a chance of someone responding.
    HTH?
    Tony

  • I just downloaded a few ITunes Apps to my PC using windows 8 and they will not work.  Suggestions?  Thank you.

    I just downloaded a few ITunes Apps to my PC using windows 8 and they will not work.  Suggestions?  Thank you.

    The apps can only be run on an iOS device.   They will not run on your PC.

  • When should I use static variable and when should not? Java essential

    When should I use static variable and when should not? Java essential

    Static => same value for all instances of the class.
    Non-static => each instance can have its own value.
    Which you need in which circumstances is completely up to you.

  • The recipient cant see "middle of reply or typing" bubble in imessage. Could it be that I am using iOS 8 and they are not?

    The recipient cant see "middle of reply or typing" bubble in imessage. Could it be that I am using iOS 8 and they are not? Has any of your friends pose this as a minor problem? Is there a setting that I didn't enable?

    ''rojere [[#question-1055991|said]]''
    <blockquote>
    i try to keep my thumb palms off the mouse pad when i am typing but every now and then my screen resizes larger or smaller until i take my left palm off the keyboard base its only when my left palm is resting on the base next to the touch pad. i type pretty fast so it gets annoying and yes it also jumps screens or reverts back to previous message and i have to choose ctrl z to undo and get back to my message i was typing... it also switches tabs on me as well... not sure why my palm being on the left of the keypad on the base should effect anything but it does after a while. and i have to stop what i am doing...and go to the firefox menu and change the screen size back down to 100% sometimes it goes up to 200-300 other times it goes down to 70-80% i find it annoying i i wish there was a way to turn off the screen resize in the setup panel. if its just left to be 100% i am happy with that... i don't need it to be bigger or smaller... there should be a way to LOCK it down... i understand that there are people out there with eye problems and needs to have the screen size increase using the + or - but there should be a lock so it just stays no matter what is happening on my keypad or touch pad or base of the pad... that screen size will not increase or decrease. unless i turn off the lock... perhaps this is something they can implement in the next version or do a quick update of the browser
    </blockquote>
    sorry that is all greek to me thanks for attempting to explain what you were trying to explain sorry i just not tech person to be able to understand or where to begin ... have good day and thanks for again trying

  • My document.numbers can not be opened how can i recover the version from yesterday i was not using time machine and it was not in icloud. is there an app i can buy that might help

    my document.numbers can not be opened how can i recover the version from yesterday? i was not using time machine and it was not in icloud. is there an app i can buy that might help

    Thanks Andy,
    I wish I could have told my sister about this as she could not open my homepage back before my new iWeb site. She now can open my site without the yet in case denial window does appear = I thank you.
    I think my iWeb site works as Noone has said otherwise from any platform etc...
    Alex L
    I do agree that should not have to be a consideration for any users so i agree that it would be great if Apple could allow simplicity to run seemlessly.
    I have had this problem since Homepage, and here is
    what has worked for me. I send out the link, and
    then for PC users I send the link with "<" after the address (without quotation
    marks. e.g., <http://site.com>).
    I also put a note that if that doesn't work, to just
    copy and paste the link into a browser. With that I
    have only had 1 person say they still can't open.
    Everyone else gets it to work.
    It's a lot to do and seems like a hassle, but you get
    used to it.
    Hope this helps!
    Andy Martini
    PS - APPLE! When are you going to fix this??! It
    seems like such a small thing yet you guys have been
    stumped for YEARS on this!

  • TS1368 I am using iPad 3 and I can not connect to iTunes Store,if I want to download it say you can not connect

    My question has not be answers yet,I am using iPad 3 and I can not get to connect to iTunes Store to download anything.

    The iPad Screen is almost square, HD TVs are rectangular so will never be full screen.  When watching movies, the movies native aspect ratio will be used rather than the iPads screen aspect ratio so will look full screen if the movie is full screen, but most likely will be seen in wide screen letter box format. with black bars across the top and bottom as that what most movies from iTunes are in, format wise

  • Hello, I'm using Mountain Lion and mail does not leave the mails on the server, either on iCloud nor on other suppliers (orange). They are both using iMap protocol... Any place where I could change this ? Thanks for any hall; Christian

    Hello, I'm using Mountain Lion and mail does not leave the mails on the server, either on iCloud nor on other suppliers (orange). They are both using iMap protocol... Any place where I could change this ? Thanks for any hall; Christian

    Under what circumstances does mail "not leave the mails on the server"?
    If you mean that you delete them (or move them out of the inbox) on one device and then find them not in the inbox on the server when you look from another device, that's how IMAP is supposed to work. (Note that the deletion or moving might be the result of rules you have set up in Mail.)
    If you mean something else, please explain your issue in more detail.

  • I tried to use the iPhone hot spot feature for the first time to use my kindle outside. I followed the directions n I saw the network came up I used my password and I could not connect. What am I'm doing wrong. Please help

    I tried to use the iPhone hot spot feature for the first time to use my kindle outside. I followed the directions n I saw the network came up I used my password and I could not connect. What am I'm doing wrong. Please help

    I tried to use the iPhone hot spot feature for the first time to use my kindle outside. I followed the directions n I saw the network came up I used my password and I could not connect. What am I'm doing wrong. Please help

  • Encrypt and decrypt using dbms_crypto.hash

    hi to all i am newbie here and i've just want to ask if how can i decrypt the encryted password.
    v_pass_string = 'qwerty';
    lower(dbms_crypto.hash(to_clob(v_pass_string),3))
    The out is: b1b3773a05c0ed0176787a4f1574ff0075f7521e
    and i want to output it into original data which is *'qwerty'*
    please help...
    thanks in advance

    You can't.
    HASH is not an encryption algorithm, it is a one-way hashing algorithm. HASHed cannot be converted back to the original value. This is one reason they are used for passwords as they offer the best security.
    If you want to encrypt and decrypt values you would use the ENCRYPT and DECRYPT functions of the DBMS_CRYPTO package...
    http://www.psoug.org/reference/dbms_crypto.html

  • Creating & Using .jar files and manifests

    I've read through hundreds of online tutorials on creating and using .jar's, but it's surprising how unhelpful they really are.
    I've been trying to make a java program of mine standalone, so I can distribute it to others and allow them to run it without use of a compiler, etc (ideally just a .exe or .bat that they double click on). Everything I've found says I need to create a .jar of my program in order to do this. I was finally able to create a .jar but I got different errors relating to "main-class" and "manifest" issues...I tried running it with javaw.exe and had the same problem.
    Some tutorials briefly discuss "meta manifest's", other's skip the concept all together in creating .jar's. I created a jar with:
    jar cf A2.jar c:\jarTester.java
    after changing my command prompt path to
    C:\Program Files\Java\jdk1.6.0_01\bin
    It created the .jar, but nothing worked. As above, it gave me errors relating to the "Main-Class" and "Manifest". So here's my question:
    What involvement does a "manifest" play in .jar's, and how do I create/use one to create a .jar? Why is it necessary to specify the "Main-Class" when I have already done so in my .java file?
    I believe that once I can get this "Main-Class" and "Manifest" problem straightened out, I will be able to create a batch file with the line:
    java -jar A2.jar
    is this correct? THANKS.

    I've read through hundreds of online tutorials on
    creating and using .jar's, but it's surprising how
    unhelpful they really are.really, hundreds?
    I've been trying to make a java program of mine
    standalone, so I can distribute it to others and
    allow them to run it without use of a compiler, etc
    (ideally just a .exe or .bat that they double click
    on). Everything I've found says I need to create a
    .jar of my program in order to do this. Make up your mind, do you want to make a jar or an exe?
    I was
    finally able to create a .jar but I got different
    errors relating to "main-class" and "manifest"
    issues...I tried running it with javaw.exe and had
    the same problem.
    Some tutorials briefly discuss "meta manifest's",
    other's skip the concept all togetherthat's because the manifest isn't usually necessary
    in creating
    .jar's. I created a jar with:
    jar cf A2.jar c:\jarTester.javaugh, that won't work. you need to put the class file in there, not the source. or you can put the source in as well if you want, but the class is necessary
    i'm ignoring the rest of this post for now
    go back to Google and type in jar manifest and read more

  • I am using RHEL 5 and I am not able to connect with network

    Hi Friends,
    I am using RHEL 5 and unable to connect with network. I have also tried to install RHN setup but I am unable to complete the setup. Since it is trying to connect with RHEL.
    #yum install rhn-setup
    Please help me to understand the cause of the error, so that it will help me to go for the next step.
    Thank You
    Murali

    Murali wrote:
    Hi Friends,
    I am using RHEL 5 and unable to connect with network. I have also tried to install RHN setup but I am unable to complete the setup. Since it is trying to connect with RHEL.
    #yum install rhn-setup
    Please help me to understand the cause of the error, so that it will help me to go for the next step.
    Thank You
    Murali
    Error?  I don't see any error.
    Process that have errors issue error messages and codes.  They do so to assist in solving the error.  Why do you not share that information?

Maybe you are looking for

  • I lost one of my "work area" markers

    Hello, I somehow lost one of my work area markers. How do I get it back onto the timeline ? On this subject, I always find it awkward when I try to drag the left marker to the left side of my work area footage on the timeline, is there not an easier

  • Cycle Through Windows broken

    The Cycle Through Windows (CMD + ~) is broken in the Leopard Finder. It works until you cycle to the Desktop, and then it stops working. You need to click on another Finder window to get it going again. Not a show-stopper but it's definitely a very a

  • XIP build.xml missing?

    Hello In this downloaded version of 9.2 I do not see a directory BEA_HOME/weblogic92/portal/xip/ and consequently cannot build the import-export tool. Also, I am unable to specify a remote server. Has anyone else had these troubles? Any fixes? Thanks

  • CS4 printing bug with trifold?

    Hello fellow designers, I'm running InDesign CS4 on a Power PC G5 under Leopard 10.5.8, and using an Epson Artisan 50 to print. I set up a letter sized, 3-panel brochure using the feature that allows you to lock "pages" together to make a spread. Env

  • PSE8 - Bulk apply level adjustment layer.

    I have a large number of slides from the 80's that are severly yellowed/faded.  I have created a layer for level adjustment that seems to work well for most of the photos.  Is there a way to bulk apply this layer in PSE8?