Professional Web Applications Themes

binary data types used in both PostgreSQL and MySQL along with JDBC - MySQL

OK, the main program is written in Java, as part of a number of servlets, and making use of JDBC. I am using a function from the Java security API that produces binary data (this would be the message digest for now, but I need a function that is guaranteed to have a one to one relation between the input and output and a digest won't give that to me; the way I am using it, there is about 512 bits of data output). The output I am trying to work with is placed in a byte array, and I ...

  1. #1

    Default binary data types used in both PostgreSQL and MySQL along with JDBC

    OK, the main program is written in Java, as part of a number of
    servlets, and making use of JDBC. I am using a function from the Java
    security API that produces binary data (this would be the message
    digest for now, but I need a function that is guaranteed to have a one
    to one relation between the input and output and a digest won't give
    that to me; the way I am using it, there is about 512 bits of data
    output).

    The output I am trying to work with is placed in a byte array, and I
    see that PostgreSQL has a byte array data type, and MySQL has both
    binary data types and blobs. I don't know if PostgreSQL supports BLOBs
    since I have yet to find that term in the PostgreSQL doentation.

    One disturbing thing I found is that, with PostgreSQL, I will have to
    either p the output and excape any values that are not printable,
    or just escape every byte. One question, then, is what impact will
    escaping the characters in the byte array have on being able to use the
    string stored in PostgreSQL to look up appropriate rows in MySQL
    tables. Which of the binary data types in MySQL would correspond best
    with the byte array in PostgreSQL.

    An alternative would be to source a function that takes an ASCII string
    argument and returns an ASCII string result, which has a one to one
    relation between the argument and result, and for which the result
    looks random. If one where to be found, that would simplify the problem
    since the values could be stored as strings and I won't have to worry
    about storing binary data until I need to store jpeg or PNG files.

    Any suggestions?

    Thanks,

    Ted

    Ted Guest

  2. #2

    Default Re: binary data types used in both PostgreSQL and MySQL along with JDBC

    "Ted" <r.ted.byersrogers.com> wrote in message
    news:1136582034.332084.182490o13g2000cwo.googlegr oups.com...
    > OK, the main program is written in Java, as part of a number of
    > servlets, and making use of JDBC. I am using a function from the Java
    > security API that produces binary data (this would be the message
    > digest for now, but I need a function that is guaranteed to have a one
    > to one relation between the input and output and a digest won't give
    > that to me; the way I am using it, there is about 512 bits of data
    > output).
    This is only slightly related to MySQL, so perhaps you would find a more
    authoritative response on a cryptography-related newsgroup.

    I think what you want is a "collision-resistant" hash function or a "message
    authentication code" such as HMAC. I don't think this algorithm is provided
    for in MySQL. PostgreSQL has in its contrib directory pgcrypto, which
    includes an HMAC function.

    I'd recommend creating the message digests in application code, instead of
    relying on the cryptography functions in the DBMS. You'll have access to
    more robust implementations, and a greater range of digest algorithms.
    Also, you won't be beholden to the differing support for encryption
    functions in different DBMS'.

    RSA has released BSAFE Crypto-J, an implementation in Java including HMAC
    and also SHA-512 to give you your 512-bit digests:
    [url]http://www.rsasecurity.com/node.asp?id=1204[/url]

    It seems to be released under a free license, and downloadable from a site
    in Australia (I assume to avoid USA's cryptography export restrictions).
    Read [url]https://eval.rsasecurity.com.au/cgi-bin/external/license.cgi[/url] to make
    certain the license is compatible with your usage in your application.
    > An alternative would be to source a function that takes an ASCII string
    > argument and returns an ASCII string result
    When presented with problems like this, I run the digest string through
    Base-64 encoding to force the characters to be printable.

    Regards,
    Bill K.


    Bill Karwin Guest

Similar Threads

  1. MySQL and JDBC 4.0
    By Steven Buroff in forum MySQL
    Replies: 1
    Last Post: August 9th, 05:46 PM
  2. Can't set up PostgreSQL JDBC data source
    By Barry Brown in forum Coldfusion Server Administration
    Replies: 1
    Last Post: April 13th, 02:03 AM
  3. conflict types mysql and PostgreSQL
    By Pavel Stehule in forum PostgreSQL / PGSQL
    Replies: 0
    Last Post: January 31st, 02:09 PM
  4. Replies: 4
    Last Post: January 25th, 03:09 PM
  5. Mysql and binary data insert
    By Michal Weinfurtner in forum PERL Beginners
    Replies: 1
    Last Post: October 22nd, 12:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139