Serialization ruins my hash value...

Hello all,
i am in the stage of switching from asymmetric to symmetric cryptography after the successful receival of a symmetric key..
in the client now i take a string from the user and i create a hash value using the SHA1 algorithm using the following :
public static byte[] hashIt(String str){
          MessageDigest md = null;
          byte[] result=null;
          try {
               md = MessageDigest.getInstance("SHA1");
               result = md.digest(str.getBytes("UTF-8"));     
          }catch(NoSuchAlgorithmException e) {
               System.out.println("No Such Algorithm Exception "+e);     
          }catch(UnsupportedEncodingException e) {
               System.out.println("Unsupported Encoding Exception "+e);     
          System.out.println("I HASHED IT TO : "+result);
          return result;
     }i then save the message and its hashed value into an object called myPacketMessage and i use symmetric encryption to encrypt the object to a sealedObject and then serialize it to a udp packet that is being sent. Unfortunately on the receiver i obtain a different hash value than the one stored (i am not saying that i create the hash of the message and it is different from the one stored, i am saying that the hash value that i just get from the packet is different from the one that client put in it)...
In fact, i did some testing serializing and deserializing the object on the client and again the hashed value stored is different from the one retrieved. i then tried not even encrypt the object to a sealed object but just to serialize it with the following code and again it fails...
//text is a string retrieved from the user
pcktText.setHash(sp.hashIt(text));
pcktText.setMsg(text);
System.out.println("I set hash : "+pcktText.getHash());
sentPacket = sp.serializeObject(pcktText, serverIP, serverPort);
MyPacketMessage textToBeRot13=new MyPacketMessage();
          textToBeRot13=(MyPacketMessage)sp.deserializeObject(sentPacket);
System.out.println("After the serialize/deserialize the hash is : "+textToBeRot13.getHash());
          and the values are :
I set hash : [B@c55e36
After the serialize/deserialize the hash is : [B@1621e42
the function that does the serialization is the following (and i suspect that the problem is in here, but i dont know where (because it works in other cases that i store signatures in the packet!!!)
public static DatagramPacket serializeObject(MyPacketInterface myPacket, InetAddress IP, int PORT){
          byte[] sendBuf=new byte[2048];           
          DatagramPacket tempPacket=new DatagramPacket(sendBuf,sendBuf.length, IP, PORT);
          try{
               ByteArrayOutputStream byteStream = new ByteArrayOutputStream(2048);
               ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(byteStream));
               os.flush();
               os.writeObject(myPacket);
               os.flush();
               os.close();
               sendBuf = byteStream.toByteArray();
               tempPacket.setData(sendBuf);
          } catch (IOException e) {
               System.out.println("IOException "+e);
          return tempPacket;
     }and the deserialize the following :
public static MyPacketInterface deserializeObject(DatagramPacket packet){
          MyPacketInterface myPacket=null;
          byte[] recvBuf = packet.getData();
          try {
               ByteArrayInputStream byteStream = new ByteArrayInputStream(recvBuf);
               ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(byteStream));
               myPacket = (MyPacketInterface)is.readObject();
               is.close();
          } catch (ClassNotFoundException e){
               System.out.println("ClassNotFoundException :"+e);
          } catch(IOException e){
               System.out.println("IOException " +e);
          return myPacket;
     }any help would be greatly appreciated!!!

hm, could you please elaborate on that because i am not getting it...
i am not using the MD5 hash algorithm.. i am using the SHA1 to make a hash and store it on a byte[] variable .. You said that i should print out the bytes right? i think this is what i am doing in the system.out.print statements with the getHash() functions that looks like the following
public class MyPacketMessage extends MyPacket implements Serializable {
     private byte[] hash;
     private String msg;
     public MyPacketMessage(){
          super();
          this.hash=null;
          this.msg=new String();
     public byte[] getHash(){
          return this.hash;
(....)

Similar Messages

  • Hash Values in BODS

    Hello Experts,
    I am a newbie to Data Services. We are using Data Services XI 3.0 Premium. I was given a task to identify duplicates by using hash values so that there is no loss of data and at the same time we can identify the duplicates. I was able to find that functionality in Oracle. But client wants the functionality in Data Services, before it loads into Oracle. I looked everywhere, couldn't find the right information. Help would be really appreciated. Please let me know if any further information needed.
    Thank you for going through my post. I really appreciate your time.
    Thank you,
    Sandeep.

    Hi
    As per your statement "to identify duplicates considering bunch of columns together" you can implement logic using BODS built in function "gen_row_num_by_group"
    create new column in query transformation say "Dup_find" with data type int
    write logic in mapping tab as below
    gen_row_num_by_group( field1 ||  field2 || field3 || ....... ) and drag the subsequent fields in group by tab as well
    the above logic will return the row ids per group
    example
    FIELD1     FIELD2     FIELD3     DUP_FIELD
    A                    B                    C                    1
    A                    B                    C                    2
    A                    B                    C                    3
    D                    E                    F                    1
    G                    H                    I                     1
    take two query transformations in parallel
    In first query transformation, you have to filter the duplicate records using "WHERE" clause
    WHERE DUP_FIELD > 1 ( map this to one temp table to catch duplicate records )
    in second  query transformation, you can consider only unique records using "WHERE" clause
    WHERE DUP_FIELD = 1 ( map this to second temp table to catch unique records )
    hope it helps in your requirement
    Thanks
    Ahalya

  • Crystal 2008 not showing a Hash Value correctly

    We are using a SQL database with Crystal 2008.
    The Problem:
    We are having some issues displays the hash value of a varchar(20) in our crystal reports. Every value in the field is either going to be a Null or 20 characters long. We are getting varying length characters, when it should not. And it is showing blank for some of the records when the double check shows that they exist.
    What can we do to make Crystal 2008 show these fields correctly? I can use a command but that is a temporary solution for a reoccuring problem with the field in question.
    Thank you for your time!
    Dan

    We use EncryptbyCert() function in SQL. It returns only a value that is either null or 20 characters long. That is all I am able to give for information about that.

  • Delete hash value row in Bex report output

    Hi All,
    Can anybody suggest how can i remove hash value(not assigned) row in Bex report out put.
    my report looks like this:
    rows
    project position
      (hierarchy)
      WBS element
        (hierarchy)
        Order
    For each Project position and WBS element hierarchies, i did supress the " not assigned" tick in hiearchy attributes in RSH1.
    but in colums i have budget as one of the column.
      this budget comes from project position nodes to last node of WBS element but not in order, for order it will be blank but after this order a new row coming up with bold" Not assigned" with that budget amount against this not assigned.
    My problem is how can i get rid of this not assinged entire row. I search so many links in SDN, they talk about just to replace the not assigned  to some other value as blank or something like that.
    Please suggest me how can i get rid of this.
    i did tried to restrict Order with "#" but then the whole budget column getting blank.
    Regards
    Robyn.

    HI Arun,
    As i mentioned earlier, i have gone through these links, they just talk about replacing # value or Not Assigned  to some other value or blank.
    my issue is i need to get rid of that entire row.
    when i drop proj def hierarchy ,then wbs hierachy starts, sometimes at the end of wbs hierarchy i get row with #
    and sometimes after wbs hierarchy ,then order row then # row is coming.
    even after i tick supress unassigned nodes in both Projdef and wbs hierarchies.
    i am not supposed to simply replace #( not assigned) symbol or text with some other symbol or text ( thats what they discussing in these links).
    i created that macro they said in those links but its just deleting # symbol to blank not the whole row.
    hope i made my issue clear.
    i have seen so many other links as well
    [Re: Bex macros]
    Regards
    Robyn.

  • Hash values coming in extraction,how to rectify

    Dear All,
    During Extraction we are getting hash values,for which our extraction is getting failed,we manually edit the psa and doing the load from PSA to Cube,is there a way where we can restrict this hash values
    so our extraction din failed,in rskc all values are maintaide including hash.
    pls suggest.
    Thanks,
    Sapta

    Hi,
         Characters whose hexadecimal value is 00-1F these will be displayed as # and we think this is maintained in RSKC and even then the load is failed... the invalid characters are displayed as # and there by u need to stop them . Even With ALL_CAPITAL u will not be able and it wont be good to use ALL_CAPITAL in rskc.  this is part of code which i used to eliminate such cases.........and this is absolutely working fine... it will be invalid characters....
    DATA: L_S_ERRORLOG TYPE RSSM_S_ERRORLOG_INT,
             G_ALLOWED_CHAR(300) TYPE C.
    IF G_ALLOWED_CHAR IS INITIAL.
    CALL FUNCTION 'RSKC_ALLOWED_CHAR_GET'
    IMPORTING
    E_ALLOWED_CHAR = G_ALLOWED_CHAR.
    ENDIF.
    concatenate G_ALLOWED_CHAR 'abcdefghijklmnopqrstuvwxyz£Ö@[]' into G_ALLOWED_CHAR.
    in the above concatentate statement add all the characters which u want to allow apart from the allowed characters .....**
    do.
    if not RESULT co g_allowed_char.
    shift RESULT+sy-fdpos left.
    else.
    exit.
    endif.
    enddo.
    Here result is the field for which say invalid characters are coming ...above is the code to remoce invalid characters from the field Result.....
    Regards
    vamsi

  • Differences between sql id and hash value

    Hello All,
    I have read the following from Tom's web site. Ask Tom "What is a child cursor"
    Dear Tom,
    Appreicate your services to the oracle community.
    What is the column combinations which is leading to SQL_ID.  is SQL_ID = hash_value + address ?  Regards Lalitha
    Followup   August 28, 2012 - 1pm UTC:
    sql id = hash( sql statement )
    hash value is maintained for backward compatibility, sqlid is a new, better hash.
    I am just wondering what did he mean when he said "hash value is maintained for backward compatibility, sqlid is a new, better hash."?
    If both of them are the output of hash function, could someone please explain clearly what is the differences between SQL_ID and HASH_VALUE?
    Thanks for your help.

    SQL_ID is just a fancy representation of hash value | Tanel Poder's blog: IT & Mobile for Geeks and Pro…
    Regards
    Jonathan Lewis

  • Calculating HASH values with WCCP

    Ok, I'm just not getting the HASH calculations.  Can somebody please explain how the HASH values translate into subnets?
    Thanks,
    Patrick

    Patrick,
    I'm not a 100% sure of the algorithm used to determine what subnet is assigned to which WCCP bucket.  However, I do know it involves an XOR of various L3 and L4 header fields in the packet.
    To view the how the calculation has been performed you can run the hidden IOS command
    show ip wccp hash <dst-ip> <src-ip> <dst-port> <src-port>
    Router# show ip wccp 61 hash 0.0.0.0 10.88.81.10 0 0
    WCCP hash information for:
        Primary Hash:   Src IP: 10.88.81.10
      Bucket:   9
        WCCP Client: 10.88.81.12
    Router#
    Hope this helps,
    Mike Korenbaum
    Cisco WAAS PDI Help Desk
    http://www.cisco.com/go/pdihelpdesk

  • Calculating hash values for really big files

    I am using the following code to calculate the hash values of files
    public static String hash(File f, String algorithm)
                throws IOException, NoSuchAlgorithmException {
            if (!f.isFile()) {
                throw new IOException("Not a file");
            RandomAccessFile raf = new RandomAccessFile(f, "r");
            byte b[] = new byte[(int) raf.length()];
            raf.readFully(b);
            raf.close();
            MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
            messageDigest.update(b);
            return toHexString(messageDigest.digest());
        }Now the problem is, for really big files, 100 MB or over, I get an OutOfMemoryError.
    I have used the -Xms and -Xms options to increase the JVM heap size, and untimately made it to work. However, I think this is lame and there is also a limit to the -Xmx option.
    Is there any other way I can calculate the hash values of these really big files?
    Thanks a lot in advance.

    why do u open the file the way u do ?
    why to u upload ALL the file AT ONCE into the memory ?
    i would do it like this:
    FileInputStream fis = new FileInputStream (f);
    int fileSize = f.available();
    byte buffer[] = new byte[1000];
    MessageDigest messageDigest = MessageDigest.getInstance(algorithm);
    for(int read = 0;read < fileSize;read +=1000;)
    if(fis.available() > 1000)
    fis.read(buffer, read, 1000);
    else if(fis.available() > 0)
    fis.read(buffer, read, fis.available());
    else
    break;
    messageDigest.update(b);
    fis.close();
    return toHexString(messageDigest.digest());

  • Hash value in report

    Hi sdn,
    I'm getting hash value in report for one infoobject,that is for 0customer .Could you pls let me know how to remove that particular problem.
    thanks
    R

    Hi
    So u have records as follows:
    ckf            Customer Text       Value
    Base         # Not Assigned      -59,286.60
    value
    So as for the above...if there is no data as the JR.. said,it will display in that row as # or Not Assigned.
    1.So if u want dont want to display it & then u can EXCLUDE that # values in ur FILTER as other guy says.
    2.Do as per JR..
    3. U cannot totally remove tht frm ur report...becoz..where there is dependent char. which has data
    Hope this helps.

  • Problem w. hash-value calculation for CLOB with DBMS_UTILITY.GET_HASH_VALUE

    Hello Oracle-Experts,
    I had to calculate hash-values for a corrorponding CLOB-field (see my post 'Buffer to small ORA-22835 error after migration from 9i to 10g' in forum 'database general').
    I calculate the hash-values with the DBMS_UTILITY.GET_HASH_VALUE, e.g:
         SQL> SELECT DBMS_UTILITY.GET_HASH_VALUE(LPAD('X',3998,'X'),1,POWER(2,30)) FROM dual;
         DBMS_UTILITY.GET_HASH_VALUE(LPAD('X',3998,'X'),1,POWER(2,30))
         1053896858
    Because the calculation failed with 10g I had taken a closer look at this function and realised the following results:
    VALUE                                             DBMS_UTILITY.GET_HASH_VALUE(VALUE,1,POWER(2,30))
    LPAD('X',3997,'X') 557754150
    LPAD('X',3998,'X')      1053896858
    LPAD('X',3999,'X')          888036750
    LPAD('X',4000,'X') 162062978
    LPAD('X',4001,'X')          162062978
    LPAD('X',4002,'X') 162062978
    LPAD('X',10000,'X') 162062978
    It seems to me that I can't use this function for clob-values with a length greater than 4000 characters because of collisions. Maybe someone with experience
    can give me a hint to handle this problem. Worst case i had to write my own CLOB_2_HASH function.
    TIA + Best regards
    Matthias

    Yeah, the 4000-byte limit would be a factor in working CLOBs. I if you only had 4000 bytes you would not need a CLOB in the first place.
    If you don't find something better then writing your own function might be the thing to do.

  • Who will generate hash value

    Hi Everyone,
    I need some information about hash value getting generated for every new SQl
    I think that PGA will generate hash value every time
    thanks in advance
    Shareef

    912856 wrote:
    Hi Everyone,
    I need some information about hash value getting generated for every new SQl
    I think that PGA will generate hash value every time
    PGA would "generate" the value? Isn't it that the hash-values are generated by hash functions ? If you want information about how the parsing works, please read,
    http://docs.oracle.com/cd/E11882_01/server.112/e16638/optimops.htm#i21299
    And,
    http://docs.oracle.com/cd/E11882_01/server.112/e25789/sqllangu.htm#CNCPT1740
    Aman....

  • Ora_hash - Same hash value for different inputs (Urgent)

    Hi,
    Trying to use ora_hash to join between tables but i noticed that in some cases, when working on different input value the ora_hash function generates same results.
    select ora_hash('oomeroe03|6NU3|LS006P|7884|1|17-JUL-13 13.18.22.528000|0005043|'),ora_hash('GSAHFFXTK|GCQ3|A6253S|12765|1|17-JUL-13 17.26.26.853000|0136423|')
    from dual
    Output value : 1387341941
    Oracle version is 11gR2.
    Thanks

    Why would anyone limit the hash distribution to three buckets ?
    However, one must understand that the default seed is 0.  So one input repeated gets the same hash value unless the seed is changed.
    SQL> select ora_hash(rn) , rn
      2  from
      3  (Select rownum as rn from dual connect by level < 11)
      4  order by rn;
    ORA_HASH(RN)         RN
      2342552567          1
      2064090006          2
      2706503459          3
      3217185531          4
       365452098          5
      1021760792          6
       738226831          7
      3510633070          8
      1706589901          9
      1237562873         10
    10 rows selected.
    SQL> l
      1  select ora_hash(rn) , rn
      2  from
      3  (Select rownum as rn from dual connect by level < 11)
      4* order by rn
    SQL> /
    ORA_HASH(RN)         RN
      2342552567          1
      2064090006          2
      2706503459          3
      3217185531          4
       365452098          5
      1021760792          6
       738226831          7
      3510633070          8
      1706589901          9
      1237562873         10
    10 rows selected.
    SQL> /
    ORA_HASH(RN)         RN
      2342552567          1
      2064090006          2
      2706503459          3
      3217185531          4
       365452098          5
      1021760792          6
       738226831          7
      3510633070          8
      1706589901          9
      1237562873         10
    10 rows selected.
    SQL>
    Hemant K Chitale

  • The selected signed file could not be authenticated. The file might have been tampered with or an error might have occured during download. Please verify the MD5 hash value against the Cisco Systems web site

    I am trying to load any 9.0.3 firmware on my UCM 5.0.4.2000-1 server. Every newer firmware I load throws the following error. I have verified the MD5 is correct and also downloaded the file several times with the same result. I can load the same firmware file on another UCM server and it loads fine. Any ideas?
    Thanks in advance!
    Error Message:
    The selected signed file could not be authenticated. The file might have been  tampered with or an error might have occured during download. Please verify the  MD5 hash value against the Cisco Systems web site:  9b:b6:31:09:18:15:e7:c0:97:9f:e6:fe:9a:19:94:99
    Firmware File: cmterm-7970_7971-sccp.9-0-3.cop.sgn
    UCM version: 5.0.4.2000-1

    Thanks for your reply. We have a lab environment where I maintain  UCM 5.0, 5.1, 6.0, 6.1, 7.0, 7.1 and 8.0 servers each running the latest released firmware for our QA testing team. I have downloaded and installed the latest device packages but find that if I try to install any firmware newer then 8.3.1 on either 5.0.4 or 6.0 i start getting MD5 hash authentication errors. It looks like 9.0.3 firmware should work on UCM 5.0 and 6.0 so I am lost as to why I can't seem to update any firmware for any model phone if it is newer then version 8.3.1 on either 5.0 or 6.0. while 5.1 and 6.1 work without issues. Maybe it is just a bug. I mostly wanted to see if anyone else has experienced this or if it is just me.

  • Create hash value for clob column ?

    Hi,
    does anybody know a way to calculate a hash value for a clob column (9i) ?
    DBMS_UTILITY.GET_HASH_VALUE could only handle varchar2(4000).
    Thank you!
    Regrads
    Michael
    Message was edited by:
    mseiwert

    I can't reproduce it on my 10.2.0.4.0. CTL file:
    load data
    INFILE *
    Replace into table samp
    fields terminated by ","
    trailing nullcols
    no,
    col1 Char(100000000) ,
    col2 Char(100000000) enclosed by '"' and '"'
    BEGINDATA
    1,asdf,"assasadsdsdsd""sfasdfadf""sdsdsa,ssfsf"
    2,sfjass,"dksadk,kd,ss""dfdfjkdjfdk""sasfjaslaljs"Loading:
    SQL> Create table samp
      2  (
      3  no number,
      4  col1 clob,
      5  col2 clob
      6  );
    Table created.
    SQL> host sqlldr scott/tiger control=c:\temp\samp.ctl log=c:\temp\samp.log
    SQL> select * from samp
      2  /
            NO
    COL1
    COL2
             1
    asdf
    assasadsdsdsd"sfasdfadf"sdsdsa,ssfsf
             2
    sfjass
    dksadk,kd,ss"dfdfjkdjfdk"sasfjaslaljs
            NO
    COL1
    COL2
    SQL> SY.

  • OSD fails during WinPE Install drivers - "The hash value is not correct"

    Hello everyone,
    We are facing a strange problem during OSD for one of the hardware models. We are on SCCM 2012 R2, and mainly build Windows 7
    x86 machines on various Lenovo models.
    I can see this problem I have encountered has been discussed elsewhere on this forum (especially SCCM 2007 threads) but not really sure what I have
    observed is the issue being discussed. Here is the problem....<o:p></o:p>
    We have a laptop (Lenovo x240) which has been building perfectly fine for as long as I can remember. However since last 2 days when I try to build
    the same model, we get the above error during the driver installation stage (in WinPE).<o:p></o:p>
    I referred to some of the other threads and MS blogs where they say file names with extended ASCII character may break the hash of the files (packages)
    being downloaded during OSD resulting in the error(http://blogs.technet.com/b/smsandmom/archive/2008/10/09/configmgr-2007-smsts-error-hash-could-not-be-matched-for-the-downloaded-content.aspx).
    The point is I have manually gone into the Command prompt (F8) during driver downloading stage (right after apply OS image) and checked that the drivers are getting downloaded fine (but there is not enough time for me to check individual sub folders for the
    extended ascii character problem). When it comes to installing the drivers, the TS fails and immediately the whole of the driver packages folder under D:\_SmsTaskSequence\Packages\PackageID folder becomes empty.
    There is nothing much logged in the ts log either.<o:p></o:p>
    Any thoughts? The only thing that has changed in our environment in the last 2 weeks is that we have upgraded from SCCM
    2012 SP1 to R2(CU3). All the other models have built ok since and only X240 is running into this issue.
    Would recreating the driver pack be an option here? I also understand that we also can configure the TS to refer to the package media directly from
    the DP share (instead of downloading) but we would rather not get into that at this stage as we have not tested the TS with that configuration (it might open another can of worms with package command lines etc.)
    One more point - This "The hash value is not correct" error message is only logged on the SCCM status messaging system (which can be viewed
    under the Monitoring wunderbar - Status Message Queries). I do not find it on the ts log file interestingly.
    Any help is much appreciated.<o:p></o:p>

    I've only seen this once before in a ConfigMgr 2012 RTM environment and after fighting it for a few days I ended up simply recreating the driver packages.
    -Nick O.

Maybe you are looking for

  • Open cursor for a dynamic query

    Hi, I'm using forms6i and db 10g I want to create a procedure like below      PROCEDURE pop_cursor (generic_cur IN OUT gencurtyp, querystring varchar2) IS      BEGIN           OPEN generic_cur FOR querystring;      END;where generic_cur is a Ref Curs

  • "Lights ON" in car kit - which phones?

    I've seen some threads regarding phones which no longer offer the "Lights ON" option when in the cradle. There was mention of EU directives (aka unwelcome interference and bureacracy!). As someone who currently uses a 6230i with this feature (in a CK

  • Database Diff Wizard Tool problem

    Using Oracle SQL Developer 1.5.1 Build 5440. Third Party Extension jtds-1.1.2.jar I'm trying to determine if the Database Diff Wizard Tool contains functionality to allow/support diff compares between objects found in an Oracle Db instance and object

  • Listings are not successfully sent to Rex 3.2

    Hi All, I'm facing some issues to send product listings from CRM to Rex 3.2. We configured the DCN a Product type download profile and we assigned it to Products by selecting Listings a download criteria. The Product profile has been assigned to a sp

  • ISE after power off !!

    Hi everyone, I have ISE VMWare based. Every time, when I switch the power of the server off for any reason, and turn it on again, I lose the connectivity through HTTP to the ISE but I can still ping it !!!! I couldn't know what was the issue and for