diff --git a/hmacdebug.rb b/hmacdebug.rb deleted file mode 100644 index 770ffe4..0000000 --- a/hmacdebug.rb +++ /dev/null @@ -1,57 +0,0 @@ -#!/usr/bin/env ruby - -require 'digest/sha1' - -# helper to make a 'length' long string filled with 'byte' -def byte_string(byte, length) - ([byte]*length).pack('C*') -end - -def put_bytes(s) - s.unpack('C*').each { |x| print sprintf("%02d ",x); } - puts -end - -# hmac algorithm - returns text version of hmac -def hmac(key, data, digest_object, blocksize) - # if key is too long, hash it - key = digest_object.digest(key) if key.size > blocksize - - # pad key out to blocksize - key += byte_string(0,blocksize - key.size) if key.size < blocksize - - # create pads - ipad = byte_string(0x36,blocksize) - opad = byte_string(0x5c,blocksize) - blocksize.times do |i| - #ipad[i] ^= key[i] - ipad.setbyte(i,ipad.getbyte(i) ^ key.getbyte(i)) - #opad[i] ^= key[i] } - opad.setbyte(i,opad.getbyte(i) ^ key.getbyte(i)) - end - - puts "Key: " - put_bytes(key) - puts "data: " - put_bytes(data) - puts "ipad: " - put_bytes(ipad) - puts "opad: " - put_bytes(opad) - puts - puts "hash(ipad + data)" - puts digest_object.hexdigest(ipad+data) - puts - puts "hash(opad+hash(ipad+data))" - puts digest_object.hexdigest( opad + digest_object.digest( ipad + data ) ) - - # do the HMAC and return - digest_object.hexdigest( opad + digest_object.digest( ipad + data ) ) -end - -# hmac-sha1 -def hmac_sha1(key, data) - hmac(key, data, Digest::SHA1, 64) -end - -hmac_sha1('Jefe','what do ya want for nothing?'); diff --git a/passy.js b/passy.js index 77a871b..7c599ab 100644 --- a/passy.js +++ b/passy.js @@ -1,5 +1,5 @@ /* - * passy.js - implementation of passy algorithm javascript, by Stephen Waits + * sha1.js - implementation of SHA-1 hash and HMAC algorithms in javascript, by Stephen Waits * * The MIT License * @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +/*jslint onevar: true, undef: true, nomen: true, regexp: true, newcap: true, immed: true */ + /* * Given a "text" (i.e. "amazon.com") and a "secret" (i.e. "mypassword") return an * array of four Passy'fied passwords. @@ -39,12 +41,15 @@ var passy = function(text,secret) */ var passify = function(hexstr) { - // lookup table to convert a single character to a symbol - var symtab = { "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", "8":"*", "9":"(", "0":")" }; + var + // lookup table to convert a single character to a symbol + symtab = { "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", "8":"*", "9":"(", "0":")" }, + + // misc + odd = true, i; // convert every other numerical character to a symbol - var odd = true; - for(var i=0;i - - - - - - - -
- Site Name:
-
- Secret Passphrase:
-
-
- Site Password:
- -
- - diff --git a/passytiny.js b/passytiny.js deleted file mode 100644 index 03344cd..0000000 --- a/passytiny.js +++ /dev/null @@ -1,9 +0,0 @@ -(function(){var q=function(a){var c=[],d=a.length*8,b;for(b=0;b>5]|=(a.charCodeAt(b/8)&255)<<24-b%32;return c},r=function(a){var c=[],d=a.length,b,e;for(b=0;b>3]|=e<<24-4*(b%8)}return c},m=function(a){var c="",d=a.length*4,b,e;for(b=0;b>2]>>(3-b%4)*8;c+="0123456789abcdef".charAt(e>>4&15)+"0123456789abcdef".charAt(e&15)}return c},n=function(a){var c="",d=a.length*4,b,e,j;for(b=0;b>2]>>8*(3-b%4)&255)<<16|(a[b+1>>2]>>8*(3-(b+1)%4)&255)<<8|a[b+2>>2]>>8*(3-(b+2)%4)&255;for(e=0;e<4;e+=1)c+=b*8+e*6<=a.length*32?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(j>>6*(3-e)&63):""}return c},f=function(a,c){return a<>>32-c},o=function(a,c){var d=(a&65535)+(c&65535);return((a>>>16)+(c>>>16)+(d>>>16)&65535)<<16|d&65535},k=function(a,c,d,b,e){var j=(a&65535)+(c&65535)+(d&65535)+(b&65535)+(e&65535);return((a>>>16)+(c>>>16)+(d>>>16)+(b>>>16)+(e>>>16)+ -(j>>>16)&65535)<<16|j&65535},u=function(a,c){var d=[],b,e,j,l,p,v,s,g,w,h=[1732584193,4023233417,2562383102,271733878,3285377520],t=[1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393, -1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782]; -a[c>>5]|=128<<24-c%32;a[(c+65>>9<<4)+15]=c;w=a.length;for(s=0;sa/8)c[15]&=4294967040;for(a=0;a<=15;a+=1){b[a]=c[a]^909522486;e[a]=c[a]^1549556828}b=u(b.concat(this.strToHash),512+this.strBinLen);b=u(e.concat(b),672);return d(b)}};window.jsSHA=x})(); -var passy=function(q,r){var m=function(f){var o={"1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")"},k=true;for(i=0;i - - - - Sha1 - - - - - - -
Calculating...
- - diff --git a/sha1.js b/sha1.js index 1116811..ff3c4ab 100644 --- a/sha1.js +++ b/sha1.js @@ -1,3 +1,29 @@ +/* + * passy.js - implementation of passy algorithm in javascript, by Stephen Waits + * + * The MIT License + * + * Copyright (c) 2010 Stephen Waits + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + /*jslint onevar: true, undef: true, nomen: true, regexp: true, newcap: true, immed: true */ var SHA1 = (function() // SHA1 "namespace"