Hash values ​​do not match (possibly related to encoding?)

I am sending a value from my front-end (Flex) to the end (Oracle) along with a hash for the value.

In my interface, I use the as3corelib library from Google Code to calculate the HMAC hash value using the SHA1 algorithm:

com.adobe.crypto.HMAC.hash(mySecret, myMessage, com.adobe.crypto.SHA1);

In the background, I am using Oracle DBMS_CRYPTO package:

    dbms_crypto.mac(utl_raw.cast_to_raw(myMessage), dbms_crypto.hmac_sh1, 
utl_raw.cast_to_raw(mySecret));

These two values ​​usually coincide. But I came across one case when they did not. I checked that it was different and found that the front end somehow adds a funky  character to the end of the message (it cannot be seen in the back data).

I assume this is somehow coding related. Here is the source of the adobe function:

        public static function hash( secret:String, 
message:String, algorithm:Object = null ):String
        {
            var text:ByteArray = new ByteArray();
            var k_secret:ByteArray = new ByteArray();

            text.writeUTFBytes(message);
            k_secret.writeUTFBytes(secret);

            return hashBytes(k_secret, text, algorithm);
        }

I do not know how to check the hash of Oracle, since the body is encrypted.

, , - ? ( , Â, - , , , ). , , , -.

, , .

EDIT: AL32UTF8. , Flex. - Flex , UTF, , UTF? httpservice , ?

+3
2

, . UTF-8. , .

:

dbms_crypto.mac(
  utl_raw.convert(utl_raw.cast_to_raw(myMessage), 'WE8ISO8859P1', 'UTF8'),
  dbms_crypto.hmac_sh1, 
  utl_raw.cast_to_raw(mySecret)
);

WE8ISO8859P1 , .

+1

, . nls lang Oracle , .

Codo , .

0

Source: https://habr.com/ru/post/1760494/


All Articles