XMLSocket NULL byte generation

Hi,
I'm trying to get an external script to communicate with an application instance running on my Flash Interactive Media Server installation.
I've got the following server side actionscript in my AppStart():
this.socket = new XMLSocket("test");
this.socket.onXML = function(object) {
       trace("got xml!");
this.socket.connect(null, 16005);
The connection to an open socket on the localhost, port 16005 works fine, but when I try to write some xml to the socket that I accepted the connection on (running on the localhost), I never seem to get the onXML or onData callbacks on the server application instance. One question that I had was regarding the NULL byte. If the FMS application doesn't not receive the NULL byte, does that mean the callback won't happen? If so, can someone tell me how to take something like a Python string and *add* a NULL byte so that the FMS will invoke the proper onXML or onData callback when this data is sent?
Thanks.

I can't comment on the Python side, but your assumption is correct that FMS is not delivering the data because it lacks the requisite null termination character.

Similar Messages

  • "buffer too small for string or missing null byte" inserting CR in excel

    I have created a Crystal Report based on below stored procedure.
    DELIMITER $$
    DROP PROCEDURE IF EXISTS `ww_test`.`PRD_Data_sp` $$
    CREATE PROCEDURE `ww_test`.`PRD_Data_sp` (in cyear int, in cmonth int, in groupby varchar(20), in Inv_type varchar(4))
    BEGIN
      select
              CASE WHEN groupby='Date' THEN  (p.FKDAT)
                   WHEN groupby='SalesOrg' THEN  CONCAT(p.VKORG,'_',p.VTWEG)
              END ,
              sum(p.QTYSAM),
              sum(p.CASESSOLD),
              sum(p.SOLDDOL)
              from ww_test.prd_data p
              where (month(p.FKDAT)=cmonth and year(p.FKDAT)=cyear) and
                     ((p.FKART) is null or not(p.FKART in ("FAZ","ZMBB","FAS",Inv_Type))) and
                     ((p.AUART) is null or not(p.AUART in ("ZMBB")))
              Group by
                  CASE WHEN groupby='Date' THEN  (p.FKDAT)
                       WHEN groupby='SalesOrg' THEN  CONCAT(p.VKORG,'_',p.VTWEG)
                  END
              Order by
                  CASE WHEN groupby='Date' THEN  (p.FKDAT)
                       WHEN groupby='SalesOrg' THEN  CONCAT(p.VKORG,'_',p.VTWEG)
                  END;
    END $$
    DELIMITER ;
    I have used Add Command to create report based on this.
    call ww_test.prd_data_sp({?Year},{?Month},{?GroupBy},{?InvType});
    I am able to refresh the report in crystal and as well in Infoview without any problem.
    But when i try to insert this report in Excel using Live Office it gives me error. I able to insert other crystal reports without any problem.
    An error occurred while opening the report. The report does not exist; you have insufficient rights to open the report; or you cannot make a connection to the BusinessObjects Web Service. (LO 02010)
    Failed to open report (LO 26619)
    Cannot open report document 
    Buffer too small for string or missing null byte.
    can anyone suggest where i am going wrong? Any input is appreciated.
    Crystal Reports 2008
    Live Office XI 3.1
    BOEdge XI 3.1
    Xcelsius 2008
    Thanks ,
    Madhavi

    With the CurrentValue method
    Crpt.ParamFields[3].CurrentValue := memo1.Text;
    Is there another solution ?

  • Bug: NULL bytes being written to file on SMB volumes

    This is a 100% reproducable bug.
    When writing to files that are on a Samba (SMB) volume, if you are overwriting a file and making it smaller than it previously was, then OSX is writing NULL bytes to the end fo the file, which produce all sorts of problems, especially for software developers.
    How to reproduce:
    Open Terminal, navigate to a SMB volume and do the following:
    # echo "test" > test.txt
    # more test.txt
    test
    # echo "test test test test" > test.txt
    # more test.txt
    test test test test
    # echo "test" > test.txt
    # more test.txt
    "test.txt" may be a binary file.  See it anyway?
    test
    ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
    This is 100% reproducable every time.  As you can see, when you overwrite a file with a larger version, the NULL bytes are not written to the file.  But when you overwrite with a smaller version, NULL bytes are written to the end of the file.
    This problem is especially a problem for developers.  I came across this bug because I had a git repository on an SMB share/volume.  Whenever I would try to commit changes to the repository, if the git commit log file was shorter than it was in the previous commit, then git threw the error:
    error: a NULL byte in commit log message not allowed.
    fatal: failed to write commit object
    You can see this issue being discussed and reported in several places:
    http://stackoverflow.com/questions/20696643/how-do-i-keep-nul-bytes-from-appeari ng-throughout-my-git-repository-and-commit-m
    http://stackoverflow.com/questions/19705825/error-a-nul-byte-in-commit-log-messa ge-not-allowed
    https://netbeans.org/bugzilla/show_bug.cgi?id=237766
    This bug was introduced in Mavericks.  Also, remounting the volume using cifs:// doesn't make a difference.
    Does anyone have any solutions for this problem?  Has this been reported to Apple?  Does Apple know about this problem?

    Apple doesn’t routinely monitor the discussions.
    Send Apple feedback. They won't answer, but at least will know there is a problem. If enough people send feedback, it may get the problem solved sooner.
    Feedback
    Or you can use your Apple ID to register with this site and go the Apple BugReporter. Supposedly you will get an answer if you submit feedback.
    Feedback via Apple Developer

  • Best way to append null bytes to a byte array?

    I have a fixed length byte array and need to add two null bytes to its end. I have an implementation that I wrote to do this, though I was wondering whether someone could improve on what I have:
    public byte[] appendNullBytes( byte[] bytes ) {
       byte[] copyBytes = new byte[bytes.length+2];
       System.arraycopy(bytes, 0, copyBytes, 0, bytes.length);
       copyBytes[copyBytes.length-1] = 0;
       copyBytes[copyBytes.length-2] = 0;
       return copyBytes
    }

    ajmasx wrote:
    jverd wrote:
    ajmasx wrote:
    jverd wrote:
    Those aren't null bytes, they're zero bytes. A bytes can never have the value null in Java.I was using the term null interchangeably with 'zero', Which is not generally applicable in Java.Well it all depends what you are doing:
    - A null is a zero value.Not in general in Java. Null is null and zero is zero.
    - char c = '\0' defines a null character.Yes, that's the only use of "null" for primitive types.
    - A null pointer is where the address is zero and not pointing to some location in memory.Nope. A null pointer is simply one that doesn't point to any value. Nothing in the spec says it's zero.
    - A null reference is more or less the same thing (there are certain difference in the details).Nope. A null pointer and null reference in Java are the same thing.
    - A null terminated string is one where null defines the end of the string.This does not exist in Java. As the above smartass pointed out, you can put the null character at the end of a String, but that character is part of the String, not a terminator.
    >
    If you are dealing with files and other types of I/O then this concept most certainly exists. Not in Java.
    Just because you are limiting yourself to high-level use of Java, does not mean they aren't present in Java.The fact that null is precisely defined in the JLS and does not include these things means they aren't present in Java.

  • Converting ASCII text (byte array ending in null) to a String

    Hi all,
    I am trying to convert a null terminated ascii string stored in a byte array to a java String. When I pass the byte array to the String constructor it
    does not detect/interpret the null as a terminator for the ascii string. Is this something I have to manually program in? ie Check for where the null is and then
    pass that subarray of everything before the null to the String constructor?
    example of problem
    //               A   B  C   D   null   F   (note F is junk in the array, and should be ignored since it is after null)
    byte[] asciiArray = { 65, 66, 67, 68, 0,  70 };
    System.out.println(new String(asciiArray, "UTF-8"));
    //this prints ABCD"sqare icon"F

    Why do you expect the null character to terminate the string? If you come from a C or C++ background, you need to understand that java.lang.String is not just a mere character array. It's a full-fledged Java object that knows its length without having any need for null terminator. So Ascii 0 is just another character for String object. To achieve what you want to do, you have to manually loop through the byte array and stop when you encounter a null character.

  • Compare byte to null?

    I need to compare a byte to a null value for a program I am writing, in order to catch these values to stop them being printed in an output file as "<nul>".
    At first, I tried
          for (int i=1; i<=127; i++)
         if (AwaitData.received[i] == null)but this gives the error:
    StoreData.java:14: incomparable types: byte and <nulltype>
    I then tried the idea of making a Byte and setting its value to null:
    Byte NULL = null; But this doesn't work either, giving a null pointer exception when I run the for loop:
    Exception in thread "main" java.lang.NullPointerException
    at StoreData.doIt(StoreData.java:14)
    Is there any way of actually doing this?
    Thanks.

    If I change my if statement to:
    if (AwaitData.received[i] == 0)it makes the output txt file display only "<nul>".
    I know the bytes that it is printing as "<nul>" aren't in use. I am creating an FTP program and they only occur at the end of the output file. As I transfer 128 bytes at a time, the final packet I send doesn't necessarily contain 128 bytes, and so the output is showing <nul> for the bytes that actually contain nothing.
    There must be a way of catching them so they don't print ...

  • How to read a byte data from maxdb data base

    Dear All,
    I have a issue in reading the data from database table.
    I have a column named as templateData which contains the byte data (biometric template data, which comes from fingerprint device) which is DataType of LONG and CODE of BYTE.
    I am not using the below to get the template data
    Connection con = null;
      Statement stmt = null;
      ResultSet resultSet = null;
    byte[] DbBioData = new byte[1024];
    InitialContext ctx = new InitialContext();
       if(ctx == null)
         throw new Exception("Boom - No Context");
       DataSource ds = (DataSource)ctx.lookup(db_drvstr);
       con = ds.getConnection();
       stmt = con.createStatement();
       resultSet  = stmt.executeQuery(db_query + " where SUBJECT_ID='"+ username +"'");
       if(resultSet.next())
        DbBioData = resultSet.getBytes(1);
        _loc.infoT("verify", "verify::Got BioData From MAXDB" +DbBioData );
        loc.infoT("verify", "verify::Query is: " +dbquery + " where SUBJECT_ID='"+ username +"'" );
    But I am not getting the proper data, could anyone please tell me the way to read the biometric data from data base table.

    Hi Kishore,
    is it me or is there no query definition in that code?
    I see that you concatenate a "db_query" with a string to make up a WHERE clause, but the db_query is nowhere defined before.
    So at least you should provide something like
    stmt = con.createStatement("SELECT templateDate FROM <tablename> ");
    before you do anything with the query.
    Besides this: have you ever heard of SQL injections? Try to use BIND-variables instead of concatenating strings. Otherwise your application will spend much time just with parsing your queries...
    Hmm... possibly the best thing you could do about this is to read the JAVA manual for MaxDB:
    <a href="http://maxdb.sap.com/currentdoc/ef/2de883d47a3840ac4ebb0b65a599e5/content.htm">Java Manual (SAP Library - Interfaces)</a>
    Best regards,
    Lars
    Edited by: Lars Breddemann on Dec 17, 2007 1:12 PM - corrected link

  • Should I use a temp buffer to gunzip bytes to bytes?

    Folks,
    I need a method to gunzip (uncompress) a zipped-byte-array into a plain-byte-array ... The below method (based on that used for file-i/o-streams) works, but I can't figure out if using the buf  "interveening temporary buffer" is good, bad, or indifferent.
    As I understand things... There's really no memory saving in reading/writing-by-the-temporary-buffer because the input gzippedByteArray is allready wholey in memory, and we (by definition) need the whole output plain-byte-array in memory concurrently... so it'd probably be more memory efficient to NOT use temporary-buffer and just zip the WHOLE input straight into the ByteArrayOutputStream with one call to output.write
    BUT I'm not really sure of myself here... so please can anyone offer an informed opinion?
    Memory efficiency is important (I think) because we're handling XML responses, and "the odd one" might be upto maybe 200 Mb (unzipped), though "the norm" is under a meg, and 99% are under 5 meg... So I guess I need to engineer this instead of just slapping it in and seeing if it pops.
          * Returns the g-unzipped (uncompressed) version of the given
          * gzippedByteArray.
          * @param gzippedByteArray byte[] - the bytes to uncompress
          * @return byte[] - the uncompressed bytes
          * @throws IOException
         public static byte[] getUnzippedBytes(byte[] gzippedByteArray)
              throws IOException
              ByteArrayInputStream input = null;
              GZIPInputStream unzipper = null;
              ByteArrayOutputStream output = null;
              byte[] bytes = null;
              try {
                   input = new ByteArrayInputStream(gzippedByteArray);
                   unzipper = new GZIPInputStream(input);
                   output = new ByteArrayOutputStream();
                   // unzip bytes onto the output stream
                   int len;
                   byte[] buf = new byte[BUFFER_SIZE];
                   while ( (len=unzipper.read(buf)) > 0 ) {
                        output.write(buf, 0, len);
                   // return the contents
                   bytes = output.toByteArray();
              } finally {
                   IOException x = null;
                   if(unzipper!=null) try{unzipper.close();}catch(IOException e){x = e;}
                   if(output!=null) try{output.close();}catch(IOException e){x = e;}
                   if(x!=null) throw x;
              return bytes;
         }Thanking you all. Keith.

    OutputStreams aren't 'exposed by routers... Our bluddy router "encapsulates" the servlet request. It exposes a swag of setters, one of which is setExtractXml(byte[])... the upside is that you don't have to worry about content types, and request headers and all that carp... the downside is the loss of flexibility.
    What I meant was that I'll need to customise the session model (which lives in our funky router) to expose the servlet-output-stream to the action class... Then we're laughing.
    Or not... My mad tech manager reckons "it's been working that way for years"... he didn't like it when I reminded him of our "odd "unexplained" out of memory" incidents... Nope... His code... His way... Gotta luv the managment, and why do I care anyway... Do I care? Naaah. I just work here.

  • JCO.Server appends null character to string

    I am a complete SAP and JCO newbie so I'll try making as much since as I can, given the fact that I'm not familiar with SAP terminology and technology. I've been lent as a developer to another group which needs a legacy application rewritten. The application processes a RFC and decrypts the RFC encrypted payload and returns it along with a status code.
    I have made progress - I'm able to register my server with the SAP runtime and using the SAP GUI application and the help of a SAP developer, I'm able to make an RFC call to my application. I'm able to read the parameters sent from SAP and write parameters back.
    The problem is that one of the parameters I'm writing back (java.lang.String) appears to have and extra character on SAP side. On the GUI it appears as a '#' (pound) sign. The SAP developer told me the string is terminated with a null character which I know is a C/C++ thing but not a Java thing. I don't think it is a Unicode issue. The Java server is not running in Unicode mode and any attempt to set the jco.server.unicode property (I may have forgotten the exact name) to a value of 1 causes the RFC to fail.
    I think the issue is likely to be the manner in which I defined the function parameters or the manner in which I write them. The following are code snippets:
    Defining the function:
    JCO.MetaData metadata = new JCO.MetaData(Constants.FUNCTION_DECRYPT);
    metadata.addInfo(Constants.PARAMETER_SCHEME,      JCO.TYPE_INT,    255,   0,  0, JCO.IMPORT_PARAMETER, null);
    metadata.addInfo(Constants.PARAMETER_ENCRYPTED,   JCO.TYPE_STRING, 255,   0,  0, JCO.IMPORT_PARAMETER, null);
    metadata.addInfo(Constants.PARAMETER_DECRYPTED,   JCO.TYPE_STRING, 255,   0,  0, JCO.EXPORT_PARAMETER, null);
    metadata.addInfo(Constants.PARAMETER_RETURN_CODE, JCO.TYPE_INT,    255,   0,  0, JCO.EXPORT_PARAMETER, null);
    Server request handling code:
    protected void handleRequest(JCO.Function function)
                    // Obtaining import/export parameter lists.
                    JCO.ParameterList input  = function.getImportParameterList();
                    JCO.ParameterList output = function.getExportParameterList();
                    // Getting scheme and encrypted text parameters.
                    int scheme       = input.getInt(Constants.PARAMETER_SCHEME);
                    String encrypted = input.getString(Constants.PARAMETER_ENCRYPTED);
                    // Decoding base 64 string.
                    byte[] bytes = Base64.decode(encrypted);
                    // Obtaining cipher by scheme and decrypting the text.
                    AppCipher cipher = ApplicationConfiguration.getDecryptor(scheme);
                    if(cipher == null)
                                    logger.error("Unable to get cipher due to an unknown encryption scheme: " + scheme);
                    else
                                    byte[] decrypted = cipher.decrypt(bytes);
                                    String plainText = new String(decrypted);
                                    // Setting decrypted value information and return code.
                                    output.setValue(plainText, Constants.PARAMETER_DECRYPTED);
                                    output.setValue(Constants.RETURN_CODE_SUCCESS, Constants.PARAMETER_RETURN_CODE);

    I seem to have made progress. If I define the parameter type as JCO.TYPE_CHAR instead of JCO.TYPE_STRING, it works:
    metadata.addInfo(Constants.PARAMETER_DECRYPTED,   JCO.TYPE_CHAR,   255,   0,  0, JCO.EXPORT_PARAMETER, null);
    That is the only change I made. I'm still setting the parameter value as java.lang.String. I hope this won't cause issues elsewhere. I was also able to change the field definition and set it as a byte array. However, that had the problem of having to define the exact length of the byte array in the field metadata otherwise the remaining bytes would appear as null bytes on SAP side.

  • Problem in reading/writing byte array in Access database! PLEASE HELP!!

    Hi,
    I want to store a signature, which is in form of a byte array, in OLE Object field in MS Access database. I want then to retrieve this signature and verify it. The problem is that the retrieved byte array is not identical to the stored (original) one, and therefore, verifying the signature fails! Any help would be much appreciated as I can't proceed in my project without solving this problem. Here is the code to do the above mentioned functionality:
    //This part stores the signature (VT) in the table TTPTrans
    try
    { con = connect();
    ps = con.prepareStatement("UPDATE TTPTrans SET VT = ?, SigVT = ? WHERE TransID = ?");
    ps.setBinaryStream(1, new ByteArrayInputStream(vt), vt.length);
    ps.setBinaryStream(2, new ByteArrayInputStream(sigvt), sigvt.length);
    ps.setString(3, tID);
    ps.executeUpdate();
    ps.close();
    con.close();
    catch (Exception e)
    {  System.err.println(e.getMessage());
    e.printStackTrace();
    //This part retrive the signature from the table in the byte array o1:
    ResultSet result;
    byte[] o1 = null;
    byte[] o2 = null;
    try
    { con = connect();
    Statement statement = con.createStatement();
    result = statement.executeQuery("SELECT VT, SigVT" +
    " FROM TTPTrans" +
    " WHERE TransID = " + "'" +
    transID + "'");
    while (result.next()) {
    o1 = result.getBytes("VT");
    o2 = result.getBytes("SigVT");
    statement.close();
    con.close();
    catch(Exception e)
    { System.err.println(e.getMessage());
    e.printStackTrace();
    }

    In the following code, I use a ASN1SDSSSignature class, which is a subclass that I created from the Siganture class, to create and verify an SDSS signature. The ASN1SDSSSignature has two ASN1Integer class variables:
    signcryption = token.getSigncryption();
    sig.initVerify(ttpCert);
    sig.update(receivedVT);
    boolean verified = sig.verify(receivedSigVT);
    if(!verified)
    System.err.println("TTP signatire on received token invalid. ");
    notify()
    return;
    Where receivedVT and receivedSigVT are the byte arrays retrieved from th database. The following exception is thrown when I run the application:
    ASN1 type mismatch!
    Expected: codec.asn1.ASN1Integer
    In: ASN1SDSSSignature
    At index 0
    Got tag: 4 and Class: 0
    I hope this would clarify the situation and thanks in advance for any comments you may post.

  • "java.lang.NullPointerException" when use doFinal(byte[])

    My code here:
    KeyFactory kf = null;
    Cipher cipher = null;
    PrivateKey pk = null;
    byte[] symKey = null;
    try {
    Security.addProvider(new BouncyCastleProvider());
    catch (Exception e) {
    System.err.println("Error loading security provider (" +
    e.getMessage() + ")");
    try {
    kf = KeyFactory.getInstance("RSA");
    catch (NoSuchAlgorithmException ex1) {
    try {
    pk = kf.generatePrivate(priServer);
    catch (InvalidKeySpecException ex3) {
    try {
    cipher = Cipher.getInstance("RSA");
    catch (NoSuchAlgorithmException ex2) {
    catch (NoSuchPaddingException ex2) {
    try {
    cipher.init(Cipher.DECRYPT_MODE, pk);
    catch (InvalidKeyException ex4) {
    try {
    symKey = cipher.doFinal(CEK); //get encode of symmetric key
    when CEK is byte[].
    I got exception :
    java.lang.NullPointerException
         at java.math.BigInteger.remainder(BigInteger.java:1239)
         at org.bouncycastle.crypto.engines.RSAEngine.processBlock(RSAEngine.java:133)
         at org.bouncycastle.jce.provider.JCERSACipher.engineDoFinal(JCERSACipher.java:288)
    where my code wrong? Please help me!
    Note : I use bouncycastle provider.
    Thanks

    bla bla bla
    kf = KeyFactory.getInstance("RSA");
    pk = kf.generatePrivate(priServer);
    cipher = Cipher.getInstance("RSA");
    cipher.init(Cipher.DECRYPT_MODE, pk);IMHO RSA is 2-keys algorithm => you cannot use it in cipher class
    If u need encrypt use PBE for example
    PBEKeySpec pbeKeySpec;
    PBEParameterSpec pbeParamSpec;
    SecretKeyFactory keyFac;
    // Salt
    byte[] salt = ...;
    // Iteration count
    int count = 20;
    // Create PBE parameter set
    pbeParamSpec = new PBEParameterSpec(salt, count);
    // Prompt user for encryption password.
    pbeKeySpec = new PBEKeySpec(pass); //String with
    keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
    SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
    // Create PBE Cipher
    Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
    // Initialize PBE Cipher with key and parameters
    pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
    // Our cleartext
    byte[] cleartext = "This is another example".getBytes();
    // Encrypt the cleartext
    byte[] ciphertext = pbeCipher.doFinal(cleartext);

  • How to get password as string back from encrypted password byte array.

    Hi All,
    I am storing encrypted password and enc key in the database.(Code included encryptPassword method for encryption and validatePassword method for validating of password). Problem is that for some reason i need to show user's password to the user as a string as he/she entered. But i am not able to convert the encrypted password from D/B to original String.
    Tell me if any body know how to get the string password back from the encrypted password byte array after seeing my existing encryption code.
    //********* Code
    private Vector encryptPassword(byte[] arrPwd)
    try
    // parameter arrPwd is the password as entered by the user and to be encrypted.
    byte[] encPwd = null;
    byte[] key = null;
    /* Generate a key pair */
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN");
    SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN");
    keyGen.initialize(1024, random);
    KeyPair pair = keyGen.generateKeyPair();
    PrivateKey priv = pair.getPrivate();
    PublicKey pub = pair.getPublic();
    /* Create a Signature object and initialize it with the private key */
    Signature dsa = Signature.getInstance("SHA1withDSA", "SUN");
    dsa.initSign(priv);
    /* Update and sign the data */
    dsa.update(arrPwd, 0, 12);
    /* Now that all the data to be signed has been read in, generate a signature for it */
    encPwd = dsa.sign();
    /* Now realSig has the signed password*/
    key = pub.getEncoded();
    Vector vtrPwd = new Vector(2);
    vtrPwd.add(encPwd);
    vtrPwd.add(key);
    return vtrPwd;
    catch (Exception e)
    private boolean validatePassword(byte[] arrPwd,byte[] encPwd,byte[] key) throws RemoteException
    try
    // arrPwd is the byte array of password entered by user.
    // encPwd is the encrypted password retreived from D/B
    // key is the array of key through which the password was encrypted and stored.
    X509EncodedKeySpec KeySpec = new X509EncodedKeySpec(key);
    KeyFactory keyFactory = KeyFactory.getInstance("DSA", "SUN");
    PublicKey pubKey = keyFactory.generatePublic(KeySpec);
    /* Encrypt the user-entered password using the key*/
    Signature sig = Signature.getInstance("SHA1withDSA", "SUN");
    sig.initVerify(pubKey);
    /* Update and sign the password*/
    sig.update(arrPwd, 0, 12);
    return sig.verify(encPwd);
    catch (Exception e)
    Help upto any extent would be appreciated.
    Thanx
    Moti Singh

    Hi All,
    I am storing encrypted password and enc key in the
    database.(Code included encryptPassword method for
    encryption and validatePassword method for validating
    of password). Problem is that for some reason i need
    to show user's password to the user as a string as
    he/she entered. But i am not able to convert the
    encrypted password from D/B to original String.No, you are not encrypting the password in your code, you are merely signing it.
    Tell me if any body know how to get the string
    password back from the encrypted password byte array
    after seeing my existing encryption code.It is impossible to retrieve the original text out of a signature.
    You should read up on some encryption basics in order to understand the difference between signing and encrypting. Then you can find examples of how to encrypt something here: http://java.sun.com/j2se/1.4/docs/guide/security/jce/JCERefGuide.html.
    Actually there is one class specifically for keeping keys secure, KeyStore http://java.sun.com/j2se/1.4/docs/api/java/security/KeyStore.html
    - Daniel

  • Socket and 0x00 byte...

    I've been working on some code to load data using the new
    flash.net.Socket class, but I seem to have a problem with files
    being sliced at '0x00' bytes...
    For example, should I try to send (download) AA BB CC DD EE
    FF 00 11 22, and then query the bytesAvailable, I get 6 as opposed
    to 9, which is the actual packet size...
    Is there a bug with the bytesAvailable getter? Or does the
    socket close on ZERO/NULL bytes... perhaps it may be something
    else?

    Thank you. I have this. Now I would to ask, if it's good way or bad, because receiving side byte array correct receive and success save, because byte[] I am using for file. Problem I have with server, because throw exception --> image. How to repair it. I tried delete row with dos.flush(), but exception is the same. But row 84.
    Error
    // Sending side
              byte[] data = getByteArrayFromInputStream(inputStream);
              DataOutputStream dos = null;
              try {
                   dos = new DataOutputStream(socket.getOutputStream());
                   dos.writeInt(data.length);
                   dos.write(data);
                   dos.flush();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    // Receiving side
         private void receiveFile() throws IOException {
              DataInputStream dis = null;
              dis = new DataInputStream(clientSocket.getInputStream());
              int length = dis.readInt();
              byte[] b = new byte[length];
              dis.read(b);
              dis.close();
    Edited by: 893807 on 22.4.2012 8:06
    Edited by: 893807 on 22.4.2012 8:11
    Edited by: 893807 on 22.4.2012 8:12

  • Reading Byte [] in JSP - Struts

    Hi,
              I am storing PDF files as BLOB object in Oracle 9i Database.
              In my struts action class I am reading the file and converting it into byte [].
              I am storing this value in the session as an object and while reading in the JSP,I am getting only null.
              But when I check the size of the byte [], it says 7,which is the actual length.
              How to read the byte [] and put it session?
              Any suggestions.
              Regards,
              Ram

    Hi Kris,
              Thank you for your inputs.
              I have tried this option also.
              Still I am getting the same issue like the "File does not begin with %PDF-".
              Actually I am getting the byte[] in my DAO class and passing that value to the action class by way of list.
              In my action class I am doing the below code.
              List lstResult = new ArrayList();
              byte[] byteArray = (byte[]) lstResult.get(0);
                             smCat.debug("DailySalesReportAction - b4 byte array");
                             // write data to output stream of response object
                             try {
                                  st = objHttpResponse.getOutputStream();
                                  smCat.debug("DailySalesReportAction - inside try");
                                  objHttpResponse.setContentType("application/pdf");
                                  objHttpResponse.setContentLength(byteArray.length);     
                                  objHttpResponse.setHeader("Content-Disposition","inline");
                                  st.write(byteArray);
                                  st.flush();
                                  st.close();
                             } catch (IOException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
              My DAO looks like this.
              public byte[] executeBlobQuery(String strQuery) {
                        java.sql.Connection vendorConn = null;
                             Blob blobResult = null;
                             int lob_length = 0;
                             BufferedInputStream bufferedInStream = null;
                             java.io.OutputStream os = null;
                             byte[] byteBuffer = null;
                             smCat.debug("Entering in executeBlobQuery DAO***************> ");
                             try {
                                  try {
                                       mConnection = getConnection();
                                  } catch (Exception e) {
                                       smCat.error(e.getMessage());
                                  // Create a static JDBC statement
                                  Statement m_stmt = mConnection.createStatement();
                                  mConnection.setAutoCommit(false);
                                  m_stmt.setFetchSize(10000);
                                                      ResultSet m_rs = m_stmt.executeQuery(strQuery);
                                  // Increment the result set
                                  if(m_rs.next()){
                                  smCat.debug("strQuery "+strQuery);
                                  //blobResult = ((OracleResultSet) m_rs).getBLOB("REPORT");
                                  //blobResult = m_rs.getBlob("REPORT");
                                  //byteBuffer = m_rs.getBytes("REPORT");
                                  //System.out.println("Length is --> "+byteBuffer.length);
                                  os = ((OracleThinBlob)blobResult).getBinaryOutputStream();
                                  smCat.debug("Blob Retrived ");
                                  //image = (oracle.sql.BLOB)m_rs.getBlob(1);
                                  lob_length = (int) blobResult.length();
                                  smCat.debug("Value is --> " + lob_length);
                                  byteBuffer = new byte[lob_length];
                                                 int length = -1;
                                                 os.write(byteBuffer);
                                  smCat.debug("Value of byteBuffer --> " + byteBuffer.length);
                                                 os.flush();
                                  mConnection.commit();
                                                 os.close();
                                  bufferedInStream =
                                       new BufferedInputStream(blobResult.getBinaryStream());
                                  byteBuffer = new byte[lob_length];
                                  bufferedInStream.read(byteBuffer, 0, lob_length);
                                  bufferedInStream.close();
                             } catch (SQLException sqe) {
                                  smCat.error(sqe.getMessage());
                             catch (IOException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
              Ram

  • Reading file containing byte data

    I am trying to read a file containing data that is in byte format. I can't look at the file and have no idea what is in there. For my first pass I would just like to see what the format is of the data in characters. Is there an easy way to do this? This is what I have done so far:
    //file is read from another method and is passed in here.
    try {
    BufferedReader f = new BufferedReader(new FileReader(file));
    String t;
    while ((t = f.readLine()) != null) {
    byte b[] = t.getBytes();
    System.out.println("bytes " + b[0]);
    System.out.println("chars " + (char)b[0]);
    catch(Exception e) {
    e.printStackTrace();
    The output is looking like this:
    bytes 72
    chars H
    bytes 74
    chars J
    bytes 81
    chars Q
    bytes -56
    chars ?
    Which one is the character value of the bytes? I am assuming the char one, but it sure seems like funny values. Also, I want to read the whole line and then get the whole line converted, not just the first byte. Isn't getBytes just getting the first byte? How can I convert the whole line after it is read (f.readLine())?
    Thanks.
    Allyson

    Well, I tried that and it still gives me just the binary or byte data (I have no idea what kind it is - I know I can't read it when I try to open it with notepad). There is a current application that uses this file and opens it and provides the data when it is opened. I am trying to look thru that code to find out what it does, but it is very confusing. It is written in c.
    Any other ideas out there as to how to open and display the correct data in a file like this? When I did the binary data open this is the kind of data I got:
    char in new loop Q
    char in new loop
    char in new loop @
    char in new loop
    char in new loop @
    char in new loop @
    char in new loop
    char in new loop
    char in new loop @
    char in new loop L
    char in new loop `
    char in new loop :
    char in new loop @
    I know that data is mostly numbers and maybe a few names, but nothing like that.
    Thanks.
    Allyson

Maybe you are looking for

  • Print & Scan differences Snow Leopard vs. Lion?

    I have an HP Officejet Pro 8500 (A910a) AiO Printer/Scanner.  It is connected to my network and accessible to many of our home devices including an iMac, a MacBook Pro, iPads and iPhones (via AirPrint).  For the purposes of this topic, I'll refer to

  • Mirroring Macbook Display on HDTV

    Hey, I have my macbook connected to an HDTV through a mini dvi to HDMI cable, and it has been working great. Suddenly though, when Mirroring is on, the image on the TV is very strange, like the colors don't match up, and there are a lot of green and

  • Yahoo DSL from Dell Desktop to ibook-wirless via Airport Extreme

    Greetings. I have just ordered a ibook G4 to replace my Dell Dimension desktop PC running Windows XP. I am currently wired to my DSL modem (Speedstream) with SBC Yahoo DSL as my ISP. I want to do the following and need some help: 1) move my Internet

  • Purchase Order restricted by Purchase Requisition

    Hi Experts, In our company, the purchase requisition is a "MUST" to create a Purchase Order. Now I want to restrict the Purchase Order to ask for a Requisition before saving. The P.O should not be saved without a valid Requisition. Please Help. Regar

  • Updating delivery date on Purchase order line items  Urgent

    Hi, I have same problem with update the Delivery date in ME22N transaction. I have used BAPI_PO_CHANGE function module. but it does not working properly. Can anybody please send the sample code. my maild id is [email protected] it_POSCHDULE-PO_ITEM =