<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/xml.xsl" type="text/xsl"?><feed xmlns="http://www.w3.org/2005/Atom">
  <title>nulog, NULL::something : out of the headphone &gt; 2006 &gt; June &gt; 03 &gt; JugemKey</title>
  <link href="http://lowreal.net/logs/2006/06/03/1"/>
  <icon>http://lowreal.net/img/banner.png</icon>
  <link rel="self" type="application/atom+xml" href="http://lowreal.net/logs/2006/06/03/1.atom"/>
  <link rel="alternate" type="application/xhtml+xml" href="http://lowreal.net/logs/2006/06/03/1.xhtml"/>
  <updated>2006-06-03T01:45:10+09:00</updated>
  <author>
    <name>cho45(砂糖)</name>
  </author>
  <id>http://lowreal.net/2006/06/03/1</id>
  <entry>
    <title>JugemKey</title>
    <link rel="alternate" type="text/html" href="http://lowreal.net/logs/2006/06/03/1.html"/>
    <link rel="alternate" type="application/xml+xhtml" href="http://lowreal.net/logs/2006/06/03/1.xhtml"/>
    <updated>2006-06-03T01:45:10+09:00</updated>
    <published>2006-06-03T01:45:10+09:00</published>
    <id>http://lowreal.net/2006/06/03/1</id>
    <category term="web"/>
    <content type="xhtml" xml:base="http://lowreal.net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>一通り weblogin.rb でも実装してみたけど、アイコンとプロフィールぐらいはかけるようにならないと使えない。</p>
        <p>hmac_sha1 って何だよとか思った。他の実装をみながら以下のように実装 (拡張性皆無)。</p>
        <pre class="Ruby">def hmac_sha1(key, str)
    key = Digest::SHA1.digest(key) if key.length &gt; 64
    key &lt;&lt; "\0" * (64 - key.length)
    ipad = "\x36" * 64
    opad = "\x5C" * 64
    (key.size - 1).times do |i|
        ipad[i] ^= key[i]
        opad[i] ^= key[i]
    end

    sha1 = Digest::SHA1.new
    sha1.update(ipad)
    sha1.update(str)
    str = sha1.digest

    sha1 = Digest::SHA1.new
    sha1.update(opad)
    sha1.update(str)

    sha1.hexdigest
end</pre>
      </div>
    </content>
  </entry>
</feed>
