Path: csiph.com!xmission!feeder.erje.net!2.eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: sci.crypt,comp.lang.java.programmer Subject: Re: Why is Java 7 converting the Password toCharArray instead of Byte in it's PBKDF2 function? Date: Tue, 19 Jun 2018 23:20:06 +0200 Lines: 33 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net fVuC2fsOQ+k/pSqCGzLKUQPzisijIUVA8TYzoTl3knZtIw2qk= Cancel-Lock: sha1:L6k3nk1gHZuZcL1cNeoWyRND6mc= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 In-Reply-To: Content-Language: en-US Xref: csiph.com sci.crypt:43719 comp.lang.java.programmer:38394 On 19.06.2018 22:18, Lothar Kimmeringer wrote: > Karl.Frank wrote: > >> The amount of byte to read is exactly defined by >> >> int BuffSize = System.in.available(); >> byte[] pwByte = new byte[BuffSize]; >> System.in.read(pwByte, 0, BuffSize); >> >> How would the program read more byte than necessary? > > InputStream.available only returns the number of bytes that > can be read without blocking. It returns an _estimate_ of that number. A conforming implementation is even allowed to sometimes or always return 0. And in fact this is what InputStream's own implementation does. > Dependent on how the data ends > up there there still might be data left to read that you > missed because of that. > > What you're doing here is a common programming error. I hope not, but may be. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/