<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Asgeirn's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 18:45:36 GMT</pubDate>
    <description>DZone Snippets: Asgeirn's Code Snippets</description>
    <item>
      <title>Password authentication without revealing your password</title>
      <link>http://snippets.dzone.com/posts/show/3975</link>
      <description>The majority of personalized web sites use some kind of form-based password authentication where you have two form fields for username and password, and a login button. When you submit your authentication, the password is sent in the clear to the server for verification against a user database.&lt;br /&gt;&lt;br /&gt;Using a Javascript SHA library and one simple onsubmit protects the password in transit and also inside the user database:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;form onsubmit="pwField.value = b64_sha256(pwField.value);"&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blog.asgeirnilsen.com/2005/11/password-authentication-without.html"&gt;Read this&lt;/a&gt; for more elaborations with increased security.</description>
      <pubDate>Wed, 09 May 2007 19:59:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3975</guid>
      <author>asgeirn (Asgeir S. Nilsen)</author>
    </item>
    <item>
      <title>Handy Iterable for a range of Integers</title>
      <link>http://snippets.dzone.com/posts/show/3792</link>
      <description>Looping a specific number of times produces code a bit too verbose in Java.  The JDK5 enhanced for statement is a handy improvement, but you still have to fall back to the traditional for statement if you want to repeat a loop, say, 10 times.&lt;br /&gt;&lt;br /&gt;Not with this implementation of Iterable.  You can use it like this:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;for (int i : new Range(100))&lt;br /&gt;    System.out.printf("I have said this %d times. Read dzone.com!%n", i);&lt;br /&gt;&lt;br /&gt;class Range implements Iterable&lt;Integer&gt; {&lt;br /&gt;    &lt;br /&gt;    private final Integer stop;&lt;br /&gt;    &lt;br /&gt;    public Range(int stop) {&lt;br /&gt;        this.stop = stop;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public Iterator&lt;Integer&gt; iterator() {&lt;br /&gt;        return new Iterator&lt;Integer&gt;() {&lt;br /&gt;            &lt;br /&gt;            private Integer counter = 0;&lt;br /&gt;&lt;br /&gt;            public boolean hasNext() {&lt;br /&gt;                return (counter != stop);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public Integer next() {&lt;br /&gt;                if (counter == stop)&lt;br /&gt;                    throw new NoSuchElementException();&lt;br /&gt;                return ++counter;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            public void remove() {&lt;br /&gt;            }};&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 10 Apr 2007 14:39:26 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3792</guid>
      <author>asgeirn (Asgeir S. Nilsen)</author>
    </item>
  </channel>
</rss>
