Problem with sha-256 digest: missing zeros!

Hi, I'm doing a "Digest" sha-256, leave a string, it's that in the digest resulting some zeros are missing!

Digest itself is not wrong: other characters are very well... for example, let's say I had a string like this:
'64C6DDE3E579B6D986968D3445D23B15CAAF128402AC560005CE2075913FDCE8363739303358303038323339330025532682B1 '.
Correct sha256 digest would be:
'0986d134680fa055c32f86738ad67108c8028a2ea6fc31d5d64b5c8e43901f42 '.
but I get
'986d13468fa055c32f86738ad6718c828a2ea6fc31d5d64b5c8e43901f42 '.

Here is my code:
String beforeHash = aString;  //each couple of chars is a hex number so ...
byte b[] = (new BigInteger(beforeHash,16)).toByteArray();
String result = getHash(b);
System.out.println(result);

public String getHash(byte[] passwd) throws NoSuchAlgorithmException{
          MessageDigest msg = MessageDigest.getInstance("SHA-256");
          msg.reset();
          byte output[] = null;
          msg.update(passwd);
          output = msg.digest();
          StringBuffer hexString = new StringBuffer();
          for(int i=0;i<input.length;i++)
               hexString.append(Integer.toHexString(0xFF & output));
          return hexString.toString();
     }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

Not a problem in Cryptography. Integer.hexString () does not preserve the leading zeros. Change to use String.format("%02X",v) or use one of the free hexagonal encoders.

Tags: Java

Similar Questions

  • Satellite C660: problem with keyboard - double or missing characters

    Hello

    Last week, I bought my first laptop - a C660.
    A few days after I bought it, I noticed that he was typing double characters or completely miss the characters.
    Now, maybe it's that I'm adjusting to the keyboard, but I was wondering if there was any problem with the keyboards?

    Jin

    Perhaps, there is a defect in material of the keyboard. Are you running Os with the factory settings? Otherwise, contact the after-sales service. they will fix for free.

  • problem with "video driver" (maybe missing?)

    Hello. I am not very savvy at all so bear with me on this... I got some a little update last night from windows (?) thing saying my video driver missing or messed up somehow and that I needed to download a new or redownload in computer it... and then my computer restarted before I downloaded it. now, I can't know where to go to find him. I could not watch a single dvd on my com for awhile now... not cool. I use windows Vista Home Basic Edition if that helps any. Please point me in the right direction to solve this problem. Thanks for your time. :)

    Hello. I am not very savvy at all so bear with me on this... I got some a little update last night from windows (?) thing saying my video driver missing or messed up somehow and that I needed to download a new or redownload in computer it... and then my computer restarted before I downloaded it. now, I can't know where to go to find him. I could not watch a single dvd on my com for awhile now... not cool. I use windows Vista Home Basic Edition if that helps any. Please point me in the right direction to solve this problem. Thanks for your time. :)

    Hey chuckfromnewjersey

    get you the drivers from the manufacturer, not through windows updates

    Microsoft hardware updates are far behind

    try to get your site in manufacturere graphics or computer cards and find the driver download section

    Search your computer or graphics card model number based on what you have and download and install the latest graphics drivers for vista

    Walter, the time zone traveller

  • Problem with installation 7520 - drivers missing and scanner does not

    I have a HP Photosmart 7520.  The scanner has stopped working.  I uninstalled and reinstalled the drivers and full software features.  It still does not work.  I ran the HP print and Scan doctor.  He said pilots were missing and reinstall.  I've made this many times now and it still does not work.  Whenever I download, it is not download the full game.  Sometimes it prints even. Any help would be appreciated.

    HiDermot,thankyouforyoureply.thatdidnotworkunforutnately.IendedupdoingasystemrestoreonmyPCtoapointwherethelaptopwasworkingproperlywiththeprinter/scannerandthisworked. Kindregards, HPSinga

  • Certificates of ASA and SHA - 256

    Hello

    I was wondering when and if ASA will support certificates with SHA-256? I know that IOS support already...

    Thank you

    / ENTOMOLOGIST

    Hi Jacob,

    Could you please confirm the signature algorithm used by the certificate?

    What is SHA2?

    You use 8.2.4 code I guess. SHA2 support is up to 8.2.4.1. I think so either you can upgrade the 8.2.4.1 code and check.

    Kind regards

    Anisha

    P.S.: Please mark this thread as solved if you feel that your request is answered.

  • Paths multiple problem with PowerVault MD3200i + Oracle Enterprise Linux (5,7)

    Hello

    I'm trying to configure MPIO on a host (running Oracle Enterprise Linux Server 5.7) connected to an Powervault MD3200i. I have a few unexpected problems with/dev/dm-0 missing after reboot.

    I configured 3 virtual disks (RAID 1) with MPIO. 3 devices have been created (/ dev/dm-0, / dev/dm-1 and/dev/dm-2).  If I mount them manually, they work very well, so I've added to the fstab. After a reboot, I checked that/dev/dm-1 and/dev/dm-2 have been automatically but is not/dev/dm-0. In fact, the/dev/dm-0 has disappeared from the directory of the device (!)

    If I rinse 'multipath f' and ' multipath - v2 "the device gets recreated, but disappears on the"
    next reboot again. How can I resolve this behavior? Can anyone help?

    Thanks in advance.

    See you soon

    I thought about it... the problem is that I had the wrong specified dev in fstab.

    Should I use the devices in/dev/map /... it worked immediately.

  • Problems with DAQmx - tasks missing when I run my application on another PC

    Hello

    I use a NI USB 6009 and my program use DAQmx and different tasks for the input and output signal.

    I created an application and I want to run this application on another PC, which doesn't have the development environment, but the runtime engine and installed MAX. This PC is connected to the NI USB 6009.

    Now, I have the problem that the tasks are missing on this PC and I get errors when I run the application.

    I wonder why these tasks are not put into the application automatically? What should I do now? Can I somehow export tasks in MAX and copy them to the other PC? Is not complicate it?

    Hi Johannes,

    Have you created your tasks of measurement and Automation Explorer?

    If this is the case, you must export the file of configuration of measurement and Automation Explorer and then import it on the other computer.

    With LabVIEW 2010, you can import a configuration via your Installer file, but I don't know if you can do it with LabVIEW 7.1

    Kind regards

  • Problem with pole-zero analysis using multisim

    Problem with pole-zero analysis using multisim

    Party a pole / zero analysis is linearizing circuit using an operational RODC analysis, in which a driver acts as a short circuit. The problem is that in your circuit, the inductor in parallel with a source of internal tension unit.

    Use a small resistor (1mOhm will do in your case) in series with the generator output functions to break the loop short-circuit.

  • Problem with I1 Profiler update icuuc46.ddl missing

    ORIGINAL TITLE: problem with the I1 Profiler update.

    Hello

    I have the same problem as other users with my Stallion - I1 Display - when I update the software; missing icuuc46.dll.
    I am still using Windows XP SP3.
    Could you please help me?
    Thank you.

    Hi ajeshdsouza,

    I just wanted to say that they contacted me X-Rite and gave me the solution to my problem. And it is easy to do. Here it is:
    «Unplug your device from your computer, then download and install this new version of X-Rite devices.»

    http://www.XRite.com/product_overview.aspx?ID=1509&action=support&SoftwareID=1262

    Once you have installed it, restart your PC and when the computer comes back to the top again, please plug the device into a USB port on the back of your PC. »

    I hope this can help more people to solve this problem.
    Thank you very much once again for your quick response and your support, I really appreciate your help.
    Best regards
    Amaury.
     
  • Problems with the sound on my PC (i.e., no noise at all). m ' said that the Sndvol32.exe file is missing

    I have problems with the sound on my PC (i.e., no noise at all).  He told me that the Sndvol32.exe file is missing.  I went through the 'fix - it' and the solution is to extract the file from the Windows XP CD.  My PC did not come with it - otherwise, how can I get this file?  Thanks in advance!

    Most of the people do not have a genuine XP bootable CD.   This is good advice if you have a true bootbale CD, but given that the majority of people have never seen one in their life, why start there?  That's why this kind of troubleshooting tips kill me...

    The fix it will not help you.

    This will help you:

    I downloaded a copy of the file you need on my SkyDrive (everyone has a SkyDrive for file sharing).

    You can download it and when you do, place a copy of the file in these two folders (assuming that Windows is installed on your C drive):

    c:\Windows\System32
    c:\Windows\System32\dllcache (this is where XP keeps backups of important files).

    Here is the link to my SkyDrive and you can get the file you need here:

    http://CID-6a7e789cab1d6f39.SkyDrive.live.com/redir.aspx?RESID=6A7E789CAB1D6F39! 311

    When you see the files available for download, you will not see the extension of file (.exe, .dll, .cpl, .sys, etc), but when download you them they will have the right extension.

    You have to put the downloaded files in the correct folders on your system.

    That may not solve all your problems, but at least you will be spending this part and we can then fix the rest.

    Of course the file must never be missing, so something has badly haywire.

    If the system is working properly, what do you think has happened since the last time, that he did not work properly?

    Describe your current antivirus and software anti malware situation: McAfee, Symantec, Norton, Spybot, AVG, Avira!, MSE, Panda, Trend Micro, CA, Defender, ZoneAlarm, PC Tools, Comodo, etc..

    No matter what you use for the antivirus/antimalware protection, I followed with some other respectable malware scanners, and then fix any problems:
    Download, install, update and do a full scan with these free malware detection programs:
    Malwarebytes (MMFA): http://malwarebytes.org/
    SUPERAntiSpyware: (SAS): http://www.superantispyware.com/
    They can be uninstalled later if you wish.
    Restart your computer and solve the outstanding issues.
  • I'm having a problem with my wireless connection. I have to keep in with zero wireless configuration to connect to the internet almost whenever I start the computer. I use downgrade XP on vista.

    I'm having a problem with my wireless connection. I have to keep in with zero wireless configuration to connect to the internet almost whenever I start the computer. Usually, you must configure only once and his game, but I have to keep on my new Dell Precision 6400 reconfigure it. I use downgrade XP on vista.

    Hi Susancav,

    Welcome to Microsoft Windows Forums!

    I'll be your message to the category of xp windows for a better answer. You can always find your message by going to my Threads in the section My Forum links at the top right of the page. http://www.Microsoft.com/windowsxp/expertzone/newsgroups.mspx

    Thank you and best regards,

    Bindu S - MICROSOFT SUPPORT
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • I have problems with my audio new laptop second hand when I plug in external speakers, it's as if some of the sound is missing. Can anyone help?

    Problem: Sound is missing for example hand singing on a piece of music.
    Laptop: Compaq Presario C700/C731TU
    Sound: High Def Conexant Smart Audio 221
    Version 4.42.0.50

    I tried updating the driver and also searched through preferences and settings but have not found a solution, this is the first place where I've been since then. IT all works very well by means of edge speakers, but even a standard set of headphones seems to miss her.

    Thanks for you suggestion, I did since then and he said that everything was working fine. I also tried a number of other suggestions from other sites, without success. I then went to do a physical inspection and when I unplugged the audio cable I noticed that the ring of metal around the entrance of my helmet was missing, I told the person, I bought the laptop. Fortunately he found on his ground, not knowing what it was and put it on the side of "just in case". I have re-installed and the whole works fine. So if someone else is reading this and is not able to resolve a similar audio problem with something to do with the software, look at the finer physical details. It could be as simple as that.

  • Problem with Simulator and MDS Digest authorization

    I work for a BlackBerry App.

    It can connect to a Web Service and ask for a response with Digest authentication.

    I did a class to connect to the Web Service. It can work.

    Now, I have a problem.

    When the Web service returns the Digest Authorizationchallenge

    I find that the response header is not a permit to Digest but a simulator base permission and MDS.

    On my PC, I got the response packet, it contains the Digest Authorization header.

    But now it has become fundamental in the Simulator.

    What is the problem with the MDS? It changed the Authorization header?

    It is inconceivable.

    Who knows what happened?

    Thank you! Martin

    I found some ideas in the following video.

    http://www.BlackBerry.com/DevMediaLibrary/view.do?name=NetworkingTransports

    Addition of property(;deviceside=true) to connection URL will be effective.

  • ACS 5.5 with EAP - TLS SHA 256 certificates

    Hi all

    Well, I just want to confirm that ACS 5.5 supports EAP - TLS with certificates SHA2.

    Thank you

    Manel

    Manel salvation,

    There was a time long deposited back enhancement to support EAP - TLS SHA 256 and obtained certificates fixed ACS 5.2 leave.

    CSCtd34175    Support for SHA2 certificates

    To answer your question, ACS 5.5 does support SHA2 certificates with eap - tls.

    ~ BR

    Jatin kone

    * Does the rate of useful messages *.

  • problem with photoshop 2015.5, everytime I open photoshop all my preferences are reset to zero. very annoying, please help?

    problem with photoshop 2015.5, everytime I open photoshop all my preferences are reset to zero. very annoying, please help? I tried my default preferences of rest, it did not work! need for this problem!

    I gave a sort of special authorizations, the reading and writing have been already checked, but it seems to work now, thx

    "Follow these steps:

    • Quit Photoshop
    • Navigate to the location of the settings Adobe Photoshop CC2015.5 folder manually.

    Location specified in this article depending on your OS: preference file works, names, places | Photoshop CC 2014

    • Make sure that the Configuration of the CC2015.5 folder has full read and write
    • Restart Photoshop and then check. »

Maybe you are looking for

  • RE: No sound

    Originally I bought HP Media center m7170n with windows XP. Now I changed to Windows 7, but no sound at all. I've updated simultaneously to new drive hard 500 GB, 4 GB of ram. I have tried driver audio redownload compatible with Windows 7, HP Web sit

  • This plugin that I need to run training in the microsoft expert zone

    Hello, I'm an Office Depot Sales Associate and I just became a member of the Microsoft Expert Zone. I'm taking the training I need for succssesfully sale of windows 8. Now, here's my problem: whenever I take training I can't view the slides because I

  • How can I get my computer to recognize my new camera?

    I just bought a new elph of Canon 100 - I loaded the software but my computer does not recognize the camera being hooked up to it - know not why this is happening - in the past I have installed other cameras without this problem - I used the disk to

  • my windows virtual machine is streaming and I do not know how to stop

    Alex jones infowars continuously in my VM so I can not shut down windows. How can I stop

  • Corruption AE6000

    Hello As the three following threads, I have to feel corruption while using the AE6000 wireless usb adapter. However, I'm unable to solve the problem by adjusting the mtu setting in my router (Linksys EA6400). I tried the adapter on two different com