MD5 - Size Of Digested Byte Array

Hey There.
After MD5 digesting and then Base64Encoding a string, I would end up with a byte array such as this:
GH70Q2Ei0cwvQNwrkvDroA==
It changes with the input, but is always 24 characters in length. I would have thought it to be 32 characters. Any reasons???
I'm doing the UTF-8 thing. Refer to code in previous post where I'm looking for critique of code.
Thanks,
Vic

I do think about what I'm doing. I know I have to
encode digested value to get data into db. I'm not
aware of HEX encoding, only BASE64.If you aware of Base64 and MD5, I suppose you know the digest size produced by MD5 and the fact that Base64 increases the size of encoded data to fixed percentage (which is less then 50%).

Similar Messages

  • Maximum size of a byte array?

    Hi,
    I'm trying to read in a file into a byte array as following:
    byte[]inputformat = new byte[1280];
    FileInputStream in= new FileInputStream(file);
    BufferedInputStream buffer= new BufferedInputStream(in);
    int len = buffer.read(inputformat);
    The problem appears when I try to access the 1024th array-element (inputformat[1024]) afterwards. Is there a limitation in the byte-arrays, or prehaps in the buffer.read-method?
    All comments are welcomed!
    Cheers,
    Slafs

    I executed the following code:
    import java.io.*;
    public class BufferTest {
        public static void main(String[] args) {
            try {
                byte[] inputFormat = new byte[1280];
                File inFile = new File(args[0]);
                FileInputStream in = new FileInputStream(inFile);
                BufferedInputStream bis = new BufferedInputStream(in);
                int len = bis.read(inputFormat);
                System.out.println("Read " + len + " bytes");
            catch (IOException e) {
                System.out.println("Error: " + e.toString());
    }To produce the following output:
    $ java BufferTest snapshot1.png
    Read 1280 bytesSo, I am not sure where your problem lies, but I don't think it's in the code you posted.
    Good luck
    Lee

  • Byte array size changes

    For some reason the size of my byte arrays change, and it is causing problems using an AES Cipher.
    The length of the byte array is 16 when I first encrypt text, but when I try and decrypt it, it tells me the length is 29. Then I have an IllegalBlockSizeException.
    Can someone explain how to overcome this problem?
    I used the UTF-8 encoding on Ubuntu 8.04

    TamalinJava wrote:
    For some reason the size of my byte arrays change, and it is causing problems using an AES Cipher.A byte[] has a fixed size, you cannot change it.
    The length of the byte array is 16 when I first encrypt text, but when I try and decrypt it, it tells me the length is 29. Then I have an IllegalBlockSizeException.
    I used the UTF-8 encoding on Ubuntu 8.04This is your problem. It translates values >= 128 to be two characters.
    Can someone explain how to overcome this problem?Don't try to write binary data as if it were text. (Write it as binary data)

  • How to read a large file(size around 100 kbytes) into a byte array in JAVA

    aa

    But I cannot use array subscript as a long value.what do you mean?
    are you rying the following:
    long aSize = 100000;
    byte[] array = new byte[aSize];
    if this is the case, then don't do it, for your 100k file int is far more than enough.
    but in case you jsut get error while:
    byte b = array[100000];
    then it's probably because you'r array is of size 100000, that means you have bytes from 0 to 99999 in there, and 100000 is one passed the end of the array.... jus in case make your array size to be 1234567 (far more than needed for your file) and see if you still get that exception, if not, then your array was too small. but if it fixes your prob, then don't leave it as it is, try to work out the right size for array and use that....
    i wouldn't recommend using static array size, since that file might some day be bigger than you expected, and then you'd have to recompile your program.
    HTH

  • Reducing size of Image or byte array

    Hello,
    I am making a program where i have to send user's screen to another PC,
    So I use class Robot to make a screen capture and send it via UDP.
    However this is still too slow, my question is: is there some library to compress the size of byte array or Image?
    Thanks for help,
    Juraj

    thanks for help i found it
    byte[] input = ...;
    // Create the compressor with highest level of compression
    Deflater compressor = new Deflater();
    compressor.setLevel(Deflater.BEST_COMPRESSION);
    // Give the compressor the data to compress
    compressor.setInput(input);
    compressor.finish();

  • Generated Webservice proxy: Maximimum size of byte array

    Hi,
    We have generated a webservice proxy with JDeveloper (version 10.1.3.4.0) from a WSDL supplied by a .Net webservice. One of the Webservice returns a byte array. We are facing a problem when the size of the returned byte array exceeds the limit of 5 MB. We have tried to increase the heap size of the OC4J but that did not solve the problem.
    Does anyone know if there is a maximum value limit which can be passed through a byte array? Is it configurable?
    A workaround would be flushing the byte array in chunks, but the webservice returns the byte array as a single returned value.
    Regards,
    Sjoerd

    Hi,
    The webservice was called by Oracle Forms. The problem was solved by Metalink Note 562561.1 - Webservice Fails To Run With java.lang.OutOfMemoryError.
    Regards,
    Sjoerd

  • From MD5-string to byte array

    Hi fellows, I'm writing a simple cracker for MD5. The hash value has to be passed at command line as argument.
    e.g.
    java Cracker 0cc175b9c0f1b6a831c399e269772661In order to decode the hash value I'm using a brute force approach: therefore I compare a series of strings with the hash value by using the method of the class MessageDigest isEqual(byte[] a, byte[] b). So I encode each string and compare the byte array I get with the byte array of the hash value.
    Here it comes the trouble I'm in:
    when I try to get a bytes array of the MD5 hash value passed as argument of the program , I do get something, but it's not something that the isEqual method of MessageDigest can use to compare. As a result any attempt during the execution of brute force fails, even though the key is one of the string being checked.
    Perhaps am I facing a format problem? Any idea?
    Sorry for my english, it's not my first language
    Thanks to whoever will help

    Almost all questions in these forums about brute force attack on MD5 (or SHA1 or SHA256 etc etc etc) are school, college or university projects and of no practical use. This is almost certainly such a project.
    Unless things have changed in the last year, there is no practical brute force attack on MD5 whereby an input can be generated from an arbitrary output even though two inputs with the same output can be fabricated. A dictionary attack is feasible if no salt is used or a known salt is used since one only has to build the dictionary for one salt value. If a different salt is used for each entry being attacked then a dictionary will be need for each salt being used. Of course if one takes the simple precaution of not using anything that is likely to be in a dictionary then the dictionary attack will likely fail.

  • How do I store an Int, a short, and multiple bytes from file in byte array

    I'm attempting to do this for a project but can't figure out how to store the three values in one byte array. This is what i've tried
    public void send(byte[] input)
              // TODO
              ByteArrayInputStream bais = new ByteArrayInputStream(input);
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              DataOutputStream dos = new DataOutputStream(baos);
              byte[] pData = new byte[100];
              try {
                   dos.writeShort(checkSum);
                   dos.writeInt(nextSeqNum);
                   pData=baos.toByteArray();
                   bais.read(pData);
              } catch (IOException e) {
              DatagramPacket dgp = new DatagramPacket(pData, pData.length);When i set pData=baos.toByteArray() it changes the size and then stops me from being able to read the other 94 bytes into the array to send. Any ideas?

    You don't need the ByteArrayInputStream at all.
    dos.writeShort(checkSum);
    dos.writeInt(nextSeqNum);
    dos.write(input);
    pData = baos.toByteArray();
    When i set pData=baos.toByteArray() it changes the sizeNo, it makes it refer to a new byte[] array containing what you've written to the BAOS. That's what it's supposed to do.

  • How can i convert object to byte array very*100 fast?

    i need to transfer a object by datagram packet in embeded system.
    i make a code fallowing sequence.
    1) convert object to byte array ( i append object attribute to byte[] sequencailly )
    2) send the byte array by datagram packet ( by JNI )
    but, it's not satisfied my requirement.
    it must be finished in 1ms.
    but, converting is spending 2ms.
    network speed is not bottleneck. ( transfer time is 0.3ms and packet size is 4096 bytes )
    Using ObjectOutputStream is very slow, so i'm using this way.
    is there antoher way? or how can i improve?
    Edited by: JongpilKim on May 17, 2009 10:48 PM
    Edited by: JongpilKim on May 17, 2009 10:51 PM
    Edited by: JongpilKim on May 17, 2009 10:53 PM

    thanks a lot for your reply.
    now, i use udp socket for communication, but, i must use hardware pci communication later.
    so, i wrap the communication logic to use jni.
    for convert a object to byte array,
    i used ObjectInputStream before, but it was so slow.
    so, i change the implementation to use byte array directly, like ByteBuffer.
    ex)
    public class ByteArrayHelper {
    private byte[] buf = new byte[1024];
    int idx = 0;
    public void putInt(int val){
    buf[idx++] = (byte)(val & 0xff);
    buf[idx++] = (byte)((val>>8) & 0xff);
    buf[idx++] = (byte)((val>>16) & 0xff);
    buf[idx++] = (byte)((val>>24) & 0xff);
    public void putDouble(double val){ .... }
    public void putFloat(float val){ ... }
    public byte[] toByteArray(){ return this.buf; }
    public class PacketData {
    priavte int a;
    private int b;
    public byte[] getByteArray(){
    ByteArrayHelper helper = new ByteArrayHelper();
    helper.putInt(a);
    helper.putInt(b);
    return helper.toByteArray();
    but, it's not enough.
    is there another way to send a object data?
    in java language, i can't access memory directly.
    in c language, if i use struct, i can send struct data to copy memory by socket and it's very fast.
    Edited by: JongpilKim on May 18, 2009 5:26 PM

  • Is there a null value that I can put into a byte array?

    I have a byte[] that I'm trying to make smaller, at the moment, in order to do so, i'm writing it byte-by-byte to another byte[] called temp. Both are set to the same size, because I don't know exactly what the initial array will compress to.
    For example, my method will write a single byte that will tell the decompressor to carry out the next instruction 5 times (eg aaaaa = 5a), but after the instruction, I want to set the 4 a's afterwards to an empty value so that I can then iterate through temp, finding out how long to make the output byte[] by counting how many null's there are.
    Eclipse is telling me null is not possible to use, I was just wondering if there is an equivalent I can use?

    That's an idea!
    The only thing is then when I come to iterate through the byte array to write it to my output array, it throws up an error that I'm trying to compare a byte to a byte[]:
              int next = 0;
              byte[] n = new byte[0];
              for (int i = 0; i < temp.length; i++) {
                   if (temp[i] != n) {
                        output[next] = temp;
                        next++;
              return output;

  • Ideas on transforming a byte array?

    I'm writing a program to compress files - I read it in, transform it and then write it out again. I'm just having a little confusion with the transforming.
    I'm keeping it as basic as possible and just starting with finding and replacing repeating bytes with an instruction of how many times the following byte is repeated. ie a a a a a = 5 a _ _ _
    In order to do this I create a temporary array to write to (initialised to the same size as the input) and then check through for repetitions. If something is repeated more than twice (3+), then a marker byte is put in (I wanted to have specific ones for however many times the byte is repeated - within reason - which is the switch statement below), the next byte is the byte to be repeated and then I want to jump forward to the next different byte.
    I then go through the temp array count the repetitions, create a new smaller byte array and write temp[] to output[] ignoring the bytes that are repeated.
    This is what I have so far, but it doesn't quite do what I want:
    public class Transformer {
         byte[] input;
         byte[] temp;
         byte[] output;
         byte rep;
         public Transformer() {
         public byte[] transform(byte[] in) {
              input = in;
              temp = new byte[in.length];
              output = new byte[count(input, temp)];
              output = compress(temp, output);
              return output;
         private int count(byte[] from, byte[] to) {
              int k = 0; // total bytes copied so far
              byte markerByte = (byte) 0xE1;
              for (int i = 0, j = 0; i < from.length; i = j) {
                   for (j = i+1; j < from.length && from[j] == from[i] && j-i < 128; j++);
                   if (j-i >= 3) {
                        to[k++] = markerByte;
                        to[k++] = (byte) (j-i);
                        to[k++] = from[j-1];
                   } else {
                        to[k] = from[k];
                        k = i+1;
              return k;
            // (the following method isn't finished)
         private byte[] compress(byte[] from, byte[] to) {
              for (int i = 0; i < from.length; i++) {
                   if (from[i] == (byte) 0xE1) {
                        System.out.println("repeat");
                   System.out.println(from);
              return to;
         private byte getRepeatByte(int numberOfRepeats) {
              byte instruction;
              switch (numberOfRepeats) {
              case 1: instruction = (byte) 0xE1; break;
              case 2: instruction = (byte) 0xE2; break;
              case 3: instruction = (byte) 0xE3; break;
              case 4: instruction = (byte) 0xE4; break;
              case 5: instruction = (byte) 0xE5; break;
              case 6: instruction = (byte) 0xE6; break;
              case 7: instruction = (byte) 0xE7; break;
              case 8: instruction = (byte) 0xE8; break;
              case 9: instruction = (byte) 0xE9; break;
              case 10: instruction = (byte) 0xEA; break;
              case 11: instruction = (byte) 0xEB; break;
              case 12: instruction = (byte) 0xEC; break;
              case 13: instruction = (byte) 0xED; break;
              case 14: instruction = (byte) 0xEE; break;
              case 15: instruction = (byte) 0xEF; break;
              default: instruction = (byte) 0xE0; break;
              return instruction;
    At the moment I'm using a marker byte in the transform() but I want to be using the switch statement to work out the right byte to put in first.
    Does anyone have any advice on if I'm doing this in a ridiculous way or if my methods won't work.. As I haven't written a decompressor yet, it's pretty hard to test!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    baftos - thank you for your advice, i will try that and see how it goes.
    Jos - it is your method and thank you very much for it! It's part of an ongoing project of mine, which is turning out to be more challenging than i originally thought - when i posted on the other forum your loop did perfectly what I was trying to do at the time. I need all the advice i can get and hence post on multiple forums.

  • JVM error while reserving big byte array

    Hi all, I've encountered a strange problem while trying to unzip a big file (~100MB):
    I have to work with it in memory so I load it into byte array - this never caused any troubles until I tried to unpack a file of such big size - more detailed investigation showed that just a line like that:
    byte[] bb = new byte[100000000] - ruins a service thread WITHOUT giving an exception (so that, try-catch around it don't react on it)!
    The system config is here:
    P4 1.4GHz, 512 RAM, JDK1.5.u6
    Anyone saw such trouble?

    What was the specific error message or symptom you saw?
    Also please include which version of java you are using (the output
    from java -version).

  • Is there a memory limitation to byte arrays?

    Everyone,
    I have a huge(16MB) CMYK source file and I am trying to convert it to a sRGB /JPEG file and then compress it.
    When I try to read that file into a byte array it chokes and throws an OutOfMemoryException. Is there a way around this?
    thanks,
    Barat.

    The data looks something like this:
    CCCCC...MMMMM...YYYYY...KKKKK...
    CCCCC...MMMMM...YYYYY...KKKKK...
    where each letter represents one byte.
    For example, the first cyan byte has cyan information
    for 8 pixels -- each bit represents cyan or no cyan, etc.
    The point is to get this data in a viewable form on screen.
    Have tried increasing the heap to 256
    Of course the problem is in a large array that holds the output information, which is ~130M
    The original file size is 16M but this was expanded to eight times the size for the PixelInterleavedSampleModel
    where one data element (a byte in this case) represents one sample of a pixel
    There must be a better way - any suggestions?

  • Reading camera's DevieInfo NOT in byte array?!

    Hello everyone,
    I am struggling to retrieve a DeviceInfo dataset from a camera that I have.
    At first I thought it will be easy, something like:
    OSErr err;
    ICACopyObjectPropertyDictionaryPB dictPB = {};
    NSDictionary* deviceDict = NULL;
    dictPB.object = [[[self leCamera] cameraID] unsignedLongValue];
    dictPB.theDict = (CFDictionaryRef*)(&deviceDict);
    err = ICACopyObjectPropertyDictionary(&dictPB, NULL);
    if (err == noErr)
    [[self window] setTitle: [deviceDict objectForKey: @"device firmware"]];
    The problem is the firmware version is not in the dictionary that I get with
    the ICACopyObjectPropertyDictionary command and yes I have the right
    deviceID(cameraID).
    The second thing that I have tried is to retrieve the object with PTPPassThru
    command which works and the firmaware is there but I get like 256 bytes
    buffer which is really tedious to work with(the problem is that there are
    variable fields in this buffer and I have to read their size every time in order
    to jump over certain number of bytes in which I am not interested.).
    So the questions that occur to me are, am I the first one who needs to do
    such a thing? I guess not. How did the guys before me accomplish it? Is
    the PTPPassThru command and the buffer processing the only way to go
    or is there some ICA function returning a dictionary with what I need.
    Any help or insights will be greatly appreciated!
    Best regards
    artOf...

    I took the hard way and retrieved the information that I needed as byte array...
    The application is functioning now, anyway if anyone has some suggestions
    they are all welcome.
    Regards
    artOf...

  • Using the jprogress bar for file byte array downloads

    I am currently using a byte array to send files back and forth between computers. To show a file is transferring i change the mouse to the hour glass but would like to use the jprogressbar.
    To send the file i read the file from one computer into a byte array, and then send it through an objectoutputstream. I am not sure how the file is sent or received though. What can i use to judge the length of time it takes to get one file from one computer to the other? In doing a debug, it looks like the oos sends the file to the other computer, and it is basically like an uploading process. is there a way for me to judge or tell how much of the file that is being uploaded is left?
    Thanks in advance

    If i know the file size how can i then check the progression? I would also like to use an progress bar on the upload of a file to the other computer, and for the download of the byte array to the other computer i could first give it the file size. if then what can i use to base my progression off of?
    i looked at this and it says i am not able to do it, but thought there might have been improvements in the jdk since then, and i might not be seeing them
    http://forum.java.sun.com/thread.jspa?threadID=357217&messageID=1490887
    Thanks

Maybe you are looking for

  • Is it possible to create a program for embedded system

    Is it possible to create a program for embedded system?

  • Exporting Photo Taken from Contacts

    I created a new contact and took a photo from within the contacts app. It didn't show up in the iPhone camera roll. How can I export this photo to iphoto?

  • LR2.6 Export folder to Catalog crashes

    I have encountered a completely reproducable error on my system. This may have existed in LR prior to 2.6, but I was finally able to isolate it and no longer have any systems running older versions. I have a current folder of images in the catalog on

  • Why can't I  access Canon Image Gateway?

    Why can't I  access Canon Image Gateway?  It freezes on my screen after asking permission to allow storage on my computer (which it doesn't let me accept or deny)

  • Screen Processing Doubt!

    Hi Friends!      I ve 5 Screens in seqential order 100 200 300 400 500    When the user is in screen 200 i want him to branch to screen 400 without going toscreen  300.   For that i ve to write this module DATA: REQSCRN LIKE SY-DYNNR VALUE ‘400’. MOD