DIY USB password generator

Having done half a dozen V-USB tutorials I decided it’s time to whip up something cool. As USB keyboards were an area untouched, I decided to make a small USB HID keyboard device that types a password stored in EEPROM every time it’s attached. A new password can be generated just by tabbing CAPS LOCK a few times (4 times to start password regeneration and one tab for each password character generated, 10 is the default password length). Below you can see the device in action:

The place I work at requires me to change my password every few months so this would be one way to skip remembering a new password altogether (as long as I remember to write it down before regenerating a new one so password can be changed :).

What is inside?

The device is powered with a simplified version of the hardware I used in my ATtiny85 USB tutorial – I stripped away the LCD, reset pullup and both capacitors. If you’re better in cramming components inside enclosures I suggest adding at least a 0.1 uF capacitor between VCC and GND, but it seems to work fine even without it:


The enclosure was graciously donated by an old 512 MB flash drive. I couldn’t make myself to break the USB connector from the circuit board inside, so I stripped appart a short USB cable instead (shown on left):

After some thinking and iterative soldering, I managed to cram everything on a tripad veroboard with 2×8 pads with the following initial setup:

I soldered the connector first, then the zener diodes, then resistors and jumpers, and finally VCC, GND and the ATtiny itself. I used the following tricks to make all ends meet:

  • D+ zener diode goes to the pad under ATtiny that is connected to GND pin
  • After the D- zener diode, only 1 pad is left for 2k2 pullup and 68 ohm resistor, so I used a jumper wire to the next pad
  • 2k2 pullup goes to a pad connected to ATtiny VCC
  • VCC goes to the pad under the ATtiny using a black jumper wire
  • I soldered the D+ 68 ohm resistor to a wrong tripad, so I used another jumper wire just barely visible behind the top left black jumper wire for GND

I was pretty satisfied the result and the fact that it actually worked! The board did not initially fit into the very snug space in the plastic enclosure, so I had to use a Dremel to trim its insides a bit, but after that, everything snapped right back (click for larger versions):




Update: For those who are building this project – I recommend you first build it on a breadboard, and only when you have it working, solder it to a veroboard. Here are two additional, extra-large pictures of the configuration I used to help you in the component layout:


Software

The device presents itself to the computer as a USB HID keyboard. To enable communication to the device, it is a boot-compliant keyboard that can receive LED status changes from the computer. HID descriptor is from Frank Zhao’s USB business card example and I also looked at Frank’s code to understand how LED state is sent to the device (in short, PC sends a control message with 1 byte of data, the LED state bit mask).

The code is mostly based on my USB HID mouse example except for the usbsconfig.h and HID descriptor changes required to implement a boot keyboard. Update: You may also want to read my USB HID keyboard post if you want to learn more. I’ve documented the code but here are some highlights if you want to understand it better:

  • PASS_LENGTH defined in the beginning controls the length of generated passwords
  • SEND_ENTER can be defined to 1 if you want the device also to send ENTER after typing the keyboard
  • measuring_message and finish_message contain the messages that are displayed when generating / saving a new password
  • buildReport() is called by the program main loop to send keypresses to PC one by one – it translates characters in messageBuffer to USB key codes on the fly
  • usbFunctionWrite() is implemented to receive the 1-byte LED state from PC – it calls caps_toggle() function every time the LED state changes
  • generate_character() is used to return random keypresses – it is currently written to return alphanumerics, hyphen and underscore (64 symbols make it simple to select one so each has equal chance of being selected without additional logic)
  • caps_toggle() does the caps-lock counting and password generation/saving

I’ve packed the source files with the schematic, critical pictures and a Makefile. In addition to “make flash” you of course need to update the fuse bits to use the PLL clock source – see details from my previous tutorial for that. I also very strongly recommend testing the device using a breadboard before soldering it, because otherwise reflashing will be a major pain.

And of course, if you build it, try it at your own risk – and remember that once you reprogram the password, nothing will be able to restore it. I recommend storing passwords generated with the device to a safe place just to be sure.

Update: Getting it from SparkFun

I found out yesterday that SparkFun is carrying an almost identical piece of hardware, the AVR Stick. So if you order one and reprogram it with this firmware (pin configuration in usbconfig.h needs to be updated in that case), you can avoid some soldering (although not all, you’ll likely need to solder in the programming header).

I asked SparkFun if they’d be interested to make a “2.0” model of their AVR Stick with actual USB connector and enclosure to go with the package, and my password generation firmware preloaded. If you think that’s a good idea, now would be a great time to send them feedback. I’d also be interested in covering additional hacks and tutorials with such a device. :)

Update 2: Indiegogo project

Alvin Chang is currently (December 1st 2012) running a Indiegogo project to build a device very similar (and inspired by) my DIY version. In case you’re interested in getting a ready-made version, be sure to check Mr. Chang’s project out: Aladdin: The Key to Your Computer.

Published by

Joonas Pihlajamaa

Coding since 1990 in Basic, C/C++, Perl, Java, PHP, Ruby and Python, to name a few. Also interested in math, movies, anime, and the occasional slashdot now and then. Oh, and I also have a real life, but lets not talk about it!

277 thoughts on “DIY USB password generator”

  1. I finally uploaded the hex file :)
    But now it looks like that windows 7 can’t recognize it , any solution for that ?

    1. Sorry, I cannot help you much; only suggestions I have are to double-check connections and that USB lines are connected to the correct pins, and maybe make sure that your ATmega is definitely running at the 16.5 MHz (fuses should be updated with AVRdude to allow this).

      As an additional tip, if electrical connections are correct, Windows should play the “bell sound” when device is connected, even if the firmware has some issues. If you don’t get that, it’s likely some connector / pullup / etc. issue. Also, zeners connected the wrong way or too “heavy” zeners may cause issues. That’s about all I can think of.

      1. All connection are fine , all components are in there place.
        Am hearing a beep sound from my pc,and I am hearing it twice,because the device connect – show error 43 and then disconnect

    1. Could you please elaborate? If you follow my USB tutorial from part 1 to part 4, then port the project to ATtiny85, and finally study the USB HID mouse tutorial, this password generator should be fairly understandable.

      Of course, if there’s a specific area that you feel is yet unaddressed, I could as well consider writing additional material on that. :)

  2. I Like this project. Is it possible to expend the code so that it will transmit whatever it’s receiving via serial connection?

    1. I’m quite sure it is, probably using AVR integrated UART functionality is the easiest way to do this, you just have to use the interrupt flags to check if a byte has been received and then schedule for transmitting that – blocking UART input (i.e. waiting for the next character) without calling usbPoll() all the time will not work.

  3. hello i am trying to figure out were all the wires and parts go im looking at the pictures but some wires and parts are not shown clearly and i dont know witch pin they go in can some one help me out with a more detailed layout of the board im trying to write up a grid system to help understand the layout heres what i have layed out so far
    the grid is maked in units each unit is measured by the holes
    a b c d e f g h
    1
    2
    3
    4
    5
    6

    zener diode 1A TO 5B
    zener diode 2B TO 3E
    JUMP 1B TO 1C
    JUMP 6B TO 5C
    2k2 pullup 6C TO 6G
    VCC 6A TO 4H
    JUMP 3A TO 1E
    68 ohm resistor 4C TO 6F
    68 ohm resistor TO 6G

    any help is greatly appreciated thank you you can ether post it here of by email at michael040990@gmail.com
    thank you soo much and awsome project

    1. Hi Michael!

      Excellent work on the reverse engineering of that picture, it might be that I could use your method of marking to help interested builders. I checked your notes against my device, here’s the results:

      2k2 pullup should go from 6C to 6H so it reaches the last ATtiny pin, VCC

      Second 68 ohm resistor goes from 3C to 6G

      Also, you could label the 3A to 1E connection as “GND” like you did with VCC. :)

      USB connector GND goes to 2A, D+ to 3B, D- to 4B and VCC to 5A

      ATtiny in 2E-2H and 5E-5H, oriented so that pin 1 is at 2H (reset), and pin 8 at 5H (VCC)

      With the above you should be good to go. Major risks are of course bad contact and cold solder joints, but with care it should work.

      1. thank you for your responce i will be working up a board with that in mind fist i will see if i can get it built on a program called fritzing http://fritzing.org/ a prototype project once done would you like to check out the board and make sure everything is were it should be before i start soldering to a real one

          1. Everything else is OK, but the 1 space jumper wire on top row is one hole too far right, it should be from B to C, not C to D.

            If you fix the drawing, I’d be happy to incorporate it to the post for any future builders – if that’s OK with you, please send it to me (either via comments or e-mail, jokkebk (sign) codeandlife.com)

          2. i have sent you a zip containing all the files i have made and also containing all your files and some additional pictures and documents my email is michael040990 (sign) gmail.com

  4. Hi jokkebk,

    Would it be to difficult to have it also insert the user name then tab and then the password and enter?

    1. No, not very. There’s already code to write static messages, only thing that would be needed is using similar code to add (hardcoded) username and tab character (see my recent usb keyboard post on links to relevant HID tables) before entering the password.

  5. Hello can somebody post the HEX file ? I tried to compile that many times and after program attiny85 thats only connecting and disconnecting but writing nothing :(

    1. I added the .hex file into project zip, don’t have the device at hand at the moment so I cannot check that it works, but there shouldn’t be any reason why it wouldn’t.

      On Mac, the device doesn’t seem to receive LED state changes. If you’re still experimenting on a breadboard, you could try to add a LED and alter the code so that the LED toggles every time the device receives keyboard LED state change (in usbFunctionWrite() method) – there might be even some hardware issue.

    1. You’ll want the one in PDIP package (through-hole component), unless you have etching capabilities for custom pcb and good solder hand for SMD parts. However, I doubt the models requested can do 16.5 MHz, even 15MT would likely need 12 MHz crystal. You’ll want a 20PU version I think. The ones you posted are all from low voltage “V” line which has limited frequency…

  6. Hello,

    Thanks for a great Article. I was wondering about the Zeners, they seem to influence the proper functionality of this device a lot. Also if some of you could post the specs of your zeners that worked, also the ones that did not work. The reason why i need these is because the 1 watt zeners are totally worthless. The 1/2w zeners are functional to the point of getting the device to be seen but the (EMI?) error keeps reconnecting them. I am just trying to figure out how to get this device going.

    Thanks a lot in advance.

    1. Yes, the electrical characteristics for USB devices seem to be a bit painful. I personally used 1/4 W spec’d zeners, and they’ve been working nicely.

      Hopefully you’ll get it working!

      1. OK with a 1/2w Diode it did show up a lot more consistently with

        ls it shows

        Bus 005 Device 002: ID 4242:e131 USB Design by Example

        and with dmesg

        [ 2423.440101] usb 5-2: new low speed USB device using uhci_hcd and address 2
        [ 2423.682894] input: codeandlife.com Passgen as /devices/pci0000:00/0000:00:1d.0/usb5/5-2/5-2:1.0/input/input10
        [ 2423.683163] generic-usb 0003:4242:E131.0001: input,hidraw0: USB HID v1.01 Keyboard [codeandlife.com Passgen] on usb-0000:00:1d.0-2/input0
        [ 2423.683206] usbcore: registered new interface driver usbhid
        [ 2423.683211] usbhid: USB HID core driver

        but no message at the caps tap and no password entry after that. I went through the code line by line but no reason for it to not work after that.

        My question is, is there another way to see what the device is doing once its connected and registered into the system?

        1. Nice to hear. If I recall correctly, someone got even better result with 1/4W zeners.

          I haven’t used AVR 1-wire debugging so I don’t know if that could be used to see what happens, and if it would work in this case. One option is to add a LED and turn it on and off at given points, that might give you an idea where the execution “goes” (e.g. if you light the LED and turn it off when you reach main loop, you’ll see if it turns off…).

          Also, there’s a possibility that Linux doesn’t send caps lock to the device like windows does. I know OS X doesn’t…

          Good luck with your efforts!

  7. hello ..please help-me.. congratulations for the project … but please help me
    How can my program with the USB reset password generator and make it (tx)deliver the password again

    1. I’m not sure I understand your question. Do you want a program on the PC to make the device send the password again?

      One way would be to modify the “caps lock listening” code so it would differentiate between caps lock and scroll lock, and use the former to regenerate password, and latter to resend it (e.g. 4 scroll lock toggles would send the password again). Of course you need to first find a way to toggle num lock programmatically on PC side.

      If manual resend is enough, re-attaching the device or adding a reset button to it is also an option.

  8. Thanks for the reply … I need is a hardlock, I believe that this design can easily be modified to send the 10 characters only when ordering the software. could you help me?

    1. A hardlock is a lot easier to do with a custom USB device (or a custom USB HID device, I have no experience on those), but of course that would require drivers. Use my USB tutorial if you want to go that way.

      However, a simple copy protection using a HID keyboard like this device is easily circumvented – just start the program, change focus to Notepad and the device spills out the password. Then one can just copy-paste the password without the device.

      You would need some type of challenge-response authentication using a shared secret, and either use a USB custom device or implement some type of caps lock / scroll lock signalling system as I described before. Both are out of scope for me to answer, but I’ll take under consideration that I might write a post about it in the future.

    1. Wow, that is really cool! One almost might be able to route it 1-sided SMT, or at least with partial SMT (although there wouldn’t be much point for that, probably)

  9. would it be possible to program a Ctrl+Alt+Del keypress? I think there’s a market for this solution as many touch-screen-only devices need to be connected to AD domains that require Ctrl+Alt+Del for logon and it can only be achieved with a physical keyboard. It would be very cool to insert a USB stick and voila the login box opens. Then you can use a virtual keyboard for the password….you just can’t use a virtual keyboard for Ctrl+Alt+Del. Honestly: if any can do this I would buy some immediately.

    1. Adding custom keypresses in front of the login credentials is easily done – all you need is to add 3 keypresses and 3 key releases in front of the queue.

      However, currently those wanting these features need to make the necessary changes themselves (or have a friend do it), just like soldering it together is needed. Another alternative is to request commercial providers like YubiKey to add such functionality.

      I may consider revisiting this project at some point in the future, though, to make such changes to firmware a bit easier, but I cannot give any guarantees as to when this would happen.

    2. I was experimenting with Win-L to lock my computer when the key was plugged in. Ctrl-Alt-Del can be achieved similarly. See my website for details.

  10. Hi jokkebk

    My passgen stopped working on win7 some time back :-(
    I tried all kinds of stuff, removing driver, installing libusb.dll, different timings etc …
    The passgen still worked on WinExp but not on win7!

    The solution i found was :
    Use an USB-Hub (mine is a cheap one from Lo***Link)
    Now its working again.

    Hope this helps somebody else

    Cheers Jan

  11. Hi! I have a question about the circuit, i’d like to reproduce the password generator on my breadboard but i haven’t any 68 ohm resistor. Can i use a bigger one?
    How can calculate the maximum value?
    Thank you very much

    Andrea

    1. Sorry, I don’t have any manufacturing capacity, and handling the ordering of parts, soldering, payment, shipping to interested parties, and possible support and returns issues is something that I’d rather not do, but rather focus on learning new stuff and writing about that in here (if I’d price my time, the password generators would also become prohibitively expensive, something like 40€ a piece). Of course, if you like the blog, you’re also welcome to donate via PayPal (donations over $10 get a free ATtiny2313 header PCB while they last :).

      I recommend you to check out YubiKey, which is a commercial solution that’s in many ways superior (consumer-grade, more versatile) to the DIY solution if you’d rather like to buy a ready-made unit. And as said, Ben might still have boards if you have a solder iron and the parts (and ISP programmer) yourself.

      1. all right men i understand, yes ofcourse i like your blog. but i’m just started so i dont know much stuff, that is why i also don’t know what a ATtiny2313 header PCB is. and also no what isp is. but thanks anyway for your reply and your link.
        but if anyone else like to help me to learn stuff like that i would appreciate it and you’re welcome to reply

        1. Sure, didn’t mean to be rude either, just thought to explain in detail why not! :) If you are just starting, take a look at my V-USB tutorial, it’s rather beginner-friendly and contains some pointers to get you started. I can also recommend avrfreaks.net forums, they have a nice tutorial section. Welcome to the world of electronics!

          1. I think this is a misunderstand because i didn’t thought that you where rude ;) so it’s okay. I defenetly wil take a look for that tuto’s. again thanks for the link, and i wish you the best with your blog

    1. If I recall correctly, AVR Stick has the D- USB data line tied to PB0 instead of PB1. Just modify usbconfig.h to reflect this pin configuration, recompile, and flash. Also, be sure to check the fuse settings, although they should be OK because the default firmware contains the V-USB temperature logger example, that also requires same crystal settings.

    1. Most straightforward way would be to use the ISP programmer that’s used to write the firmware to also write EEPROM, I’m sure there are examples out there if you google something like “avrdude write eeprom”.

      Another way would be to change the firmware so that after a delay, it resets and shows itself as custom USB device and you have custom PC side SW to update the password. But I don’t know how that is done exactly myself, either.

    2. I made mine respond to USB packets to change the stored password with the user inputs. You’d still need an ISP to programme the firmware in though. Check out Joonas’ latest blog for details.

  12. Nice tutorial and very helpful answers to questions. Thanks! My question is, I want to build one of these for the many passwords we have at work. I know the IT guys would lose it if they knew..but hey. So I need to use my password not a random one as for example to get the laptop off screen lock it’s always the same password..I am just friggin tired of typing it. So I need it to remember 3-4 passwords. Maybe use small buttons to select which pass to enter. Will that work with the tiny85 or do I need more space??
    Thank you.

  13. Hello..
    I have a question.
    When compiled with AVR Studio + Toolchain,
    An error occurs.

    C:\Users\computer\Documents\main\default/../main.c:160: undefined reference to `usbMsgPtr’
    C:\Users\computer\Documents\main\default/../main.c:211: undefined reference to `usbMeasureFrameLength’
    C:\Users\computer\Documents\main\default/../main.c:304: undefined reference to `usbInit’
    C:\Users\computer\Documents\main\default/../main.c:319: undefined reference to `usbPoll’
    C:\Users\computer\Documents\main\default/../main.c:323: undefined reference to `usbTxStatus1′
    C:\Users\computer\Documents\main\default/../main.c:325: undefined reference to `usbSetInterrupt’

    I’ve included usbdrv.h, but an error occurs.

    Sentence is strange
    Please understand.

    1. Those are defined in V-USB source files – you need to compile them, your own code, and link all together. This can be done in AVR Studio by adding several .c and .S files to a single project. There’s mention which files are needed (usbdrv.c is one) in the tutorial.

  14. Can I just take the main.c and open in a text editor and then paste it into a new sketch? I am using a MAC. So it seems ok , but the include lines

    #include
    #include
    #include
    #include
    #include

    #include “usbdrv.h” Are these libraries I need to add into my library folder? I don’t have an avr/ directory do I need to modify those first few lines?
    I am trying to get a handle on this , your help would be great.
    Thanks.

    1. The easy way out is to have all V-USB files in same directory, but it’s slightly more elegant to have them in a sub-folder, and then just add that directory to include directories (and add the necessary C and assembler files to your project) in the development tool you are using. With avr-gcc the include directory means just adding -Iusbdrv to command line options.

  15. Hello, for all time i used to check blog
    posts here in the early hours in the break of day, for the reason that
    i enjoy to find out more and more.

  16. Hi, just done mine !
    Working but as i’m in an AZERTY os, there is a mismatch with ascii table and it output qwerty to me.

    The ascii translation is done “by hand” ine the software or is there a keyboard description flag to says it ouput qwerty/azerty ?

    Where should i look before doing ascii translation in the firmware ?

    thanks =)

    1. Maybe i’m using wrong compilation options ?
      (i’m not using your makefile, since I imported your project in eclipse-avr successfully)

    2. I think the operating system usually does translation (you have made the setting somewhere in internationalization options), or then the keyboard makers of AZERTY keyboards just have a different firmware in place in the keyboards, because as far as I know, nothing will tell the device if the O/S will view it as qwerty, azerty, dvorak etc. one.

      Because the device cannot know which will it be, it’s quite O/S and setting specific which keys will actually be outputted. So you’ll need to make custom translation routines for your device, and it won’t work the same with someone who has O/S expecting QWERTY keyboards… It’s likely a design feature in USB spec – the device is stupid and just sends keys, and the O/S interprets them as it sees fit.

  17. I made a korea version avr password generator.
    Thank you Who helped

    I can’t speak english

    Though Thank you
    Who teach English for me. ^_^;

    1. Very nice, congratulations! You seem to have gotten the ENTER key also working well, and the PCBs look nice. Oh and I’m sure you will learn English just by reading interesting stuff, I know I did. :)

      PS. Removed a previous duplicate comment of yours, so now there’s only one.

  18. Can you help please I want to make this USB. But my Windows 7 Home Premium 64bit does not see any usb at the windows sign in.Do you know why this is, in your video you are using a window o/s and you don’t have any problems
    Thanks

    1. I also did the original project with Win7 64bit, so it shouldn’t be a problem. However, the project is quite susceptible to HW problems, so long wiring, bad solder joints, too heavy zeners, etc. can cause it not to work. Also, make sure you have correct fuses set so the calibration works. You may want to read earlier comments, I think I’ve outputted almost exchaustive list of things to try in there. Good luck in the project!

  19. hello, i have developed a program to enter passwords for whatever program,app or website you want when you plug in a usb but i have yet to master a piece of code to do this from logon screen. i am useless when it comes to this device, i have tried about 15 times and spent over $100 dollars for this build, would it be possible to buy one or two off u that’s already setup and working, name ur price money is no factor to me.please reply or email me asap as the eta i have on this program has been pulled back three times and the deadline is december. please help me

    1. Hi! Sorry to hear about your problems. I’m not sure if I can help – I only have 1 compact device (the one shown in the article) and it is burned in with the firmware that only sends the password. Do you just need a working prototype HW on a protoboard, or a device that can log in already, or a device that interoperates with PC software, or something else?

      Anyways, you can e-mail me at jokkebk / codeandlife.com if you’re interested in the (possibly very limited) help I can give. :)

  20. Hi, nice device. However I tried it on Linux and because of some problems with CAPS LOCK LED I could not generate password. So I wrote small script, witch make automatic LED turn on and off.

    #!/bin/bash
    # Script, that automaticly make "password generation" process

    setleds -D +caps;
    sleep 0.5;
    setleds -D -caps;
    sleep 1; # Passwd generator create new passwd and write it to console

    # Now toogle CAPS LOCK
    for i in {1..5}
    do
    setleds -D +caps;
    sleep 0.3;
    setleds -D -caps;
    sleep 0.3;
    done

    echo ""

    And one more thing. With avr-gcc-4.6 make process fail. It is because of missing “const” before PROGMEM macro. After fixing that everything works.

  21. Hi again,
    I’ve some notes for Linux systems, hopefully it helps to someone.
    1) In console (Ctrl+Alt+Fx) Caps Lock works as expected
    2) In KDE there are some problems -> solution: in function caps_toogle() change number 4 in if condition to 6. and before main loop add this one:

    #define DELAY_AFTER_INIT 1000
    volatile int j;
    // Small delay before sending data (1000ms)
    for(j=0 ; j<DELAY_AFTER_INIT ; j++)
    {
    wdt_reset();
    usbPoll();
    _delay_us(800);
    }

    while(1)....

    3) When function usbDeviceDisconnect(); is moved to first line in main() and then this code is removed

    usbDeviceDisconnect(); // enforce re-enumeration
    for(i = 0; i<250; i++) { // wait 500 ms
    wdt_reset(); // keep the watchdog happy
    _delay_ms(2);
    }

    Everything works nice under Linux and Windows, so why is there this code?
    4) Keyboard layout – when use different keyboard layouts there can be problem with numbers and ‘-‘ or ‘_’ (in CZ keyboard instead of number there are special characters). So there is my solution:

    #define ONLY_LETTERS 1 /* If we want generate only letters. Else
    * also generate "numbers" and "-" or "_".
    * This option is useful when user use
    * different keyboard layout. When is this
    * option on, then generated password contains
    * only letters (exclude y,Y,z and Z)
    * 1 - only letters
    * 0 - and "numbers"
    */

    uchar generate_character() {
    uchar counter = TCNT0 & 63;

    if(counter < 26)
    {
    // If user want keyboard independent password
    #if ONLY_LETTERS == 1
    // If 25 'z' or 'y'
    if(counter == 25 || counter == 24)
    {// Change to 'x'
    counter = 23;
    }
    #endif
    return 'a' + counter;
    }
    else if(counter < 52)
    {
    #if ONLY_LETTERS == 1
    // If 51 'Z' or 'Y'
    if(counter == 51 || counter == 50)
    {// Change to 'X'
    counter = 49;
    }
    #endif
    return 'A' + counter - 26;
    }
    // Test if user wants only letters
    #if ONLY_LETTERS == 1
    else
    return 'q';
    #else
    // Or even "numbers", "-" and "_"
    else if(counter < 62)
    return '0' + counter - 52;
    else if(counter == 62)
    return '-';
    else
    return '_';
    #endif
    }

    When ONLY_LETTERS is enabled then ,because of security reasons, user should increase a little bit PASS_LENGTH.

  22. Hello,

    I’ve found this and just this this is super great.
    I’m now considering to build one of my own (even having an YubiKey) but I need to know what is the “USBtiny programmer” that you refer in the code…

    Can you tell me more details on the hardware needed to program the device or upload the HEX to the device?

    Thank you in advance!!

    1. USBtiny is Adafruit’s inexpensive AVR programmer (just google it) which is one way to flash the firmware in the ATtiny85 chip. Another way is to use Arduino (http://codeandlife.com/2012/03/21/using-arduino-uno-as-isp/ and http://arduino.cc/en/Tutorial/ArduinoISP). There are of course tons of others. If you plan to do much AVR stuff, a dedicated programmer is useful, otherwise Arduino works well enough, and you can do lots of stuff with Arduino alone, too.

      1. Hi,

        Thanks for the reply. I’ll give this a try but will wait 1 or 2 weeks for a friend that has both AVR and PIP programmers and will let me use the AVR one.
        And most important, he also know about this subject as I am a total newbie.

        I’ll get back if something gets burn… :)

        Cheers!

  23. Hello I love the project but not as connections go, do not see anything good in the pictures, you can upload the schema to do so?

    many thanks

    1. I’m sorry I cannot quite understand what you are asking. There is a schematic showing the connections, and a veroboard picture with textual explanation of one possible component placing. Unfortunately the connections are cramped so tight that I’m not sure a drawing with connections would be much easier to understand. :( You might also want to take a look at the higher res version of the project: http://codeandlife.com/wp-content/uploads/2012/03/detail-1.jpg

  24. Hi,
    this is a great tiny project :)
    I have a Question and that’s: can I use ATtiny13 instead of tiny45/85?
    thanks,

  25. Sorry from my English. I collected device.Flashed Fuse-bits. Windows recognizes the flash drive as an unknown device. OS Windows 7. Controller – attiny85V. Firmware on the programmer Phyton, file from the archive – main.hex .

  26. Hello

    I soldered your USB password generator, but Windows recognizes the flash drive as an unknown device. I can not understand what the problem is.

    I flashed Fuse-bits. OS Windows 7, XP. Controller – attiny85V. Firmware on the programmer Phyton, file from the archive – main.hex .

    Please, help me.

    1. The V-versions are usually limited to 10 MHz, where the password generator requires 12 MHz. You might have better luck with ATtiny85 without the V. I’d try on a breadboard first before soldering. Hope you get it working!

      1. Сhanged controller. Windows recognizes the flash drive as an unknown device. What else can advise?

        1. See my comments to theycallmeshua below, step-by-step construction on a breadboard first is the best recommendation I can give, as you can separate the “do I have working components and is everything wired correctly” part and the “did I solder the device OK and am I sure nothing is touching anything it shouldn’t” :)

  27. hello, im also having a similar problem as alexxx, as where windows 7 and vista both see the usb as an unrecognized usb device. has this been tested in these more current OS. im using a tiny84 20pu. and this is driving me crazy. i have some modifications id like to make after i get this working but cant past the “getting it working” part lol.

    1. I developed the gadget with Win7 64bit so it should work well with that. The USB keyboard spec hasn’t changed much in past 10 years so everything from WinXP should work. In OS X the caps lock works differently so it cannot be used there.

      Most “unrecognized usb device” problems in my USB tutorials section have turned out to be electrical problems (too heavy zener diodes, different pull-up resistor strengths for some USB buses, wrong pins used, solder problems, etc.) so that would be my first guess. Using a breadboard and possibly following my USB tutorial to build this thing gradually might help, as you would be adding components one by one and solder problems are eliminated. But I have no 100 % certain answers available, unfortunately. :-d

      1. thanks, ill keep looking into it. could be my diodes i guess but it shouldnt be. thanks for you help. i originally was working on a breadboard but it kept connecting and disconnecting rapidly so i moved to a soldered board. which caused that to stop but its still unrecognized. ILL KEEP WORKING! i havent given up yet.

    1. The picture is quite blurry.

      Which way is your connector, GND in bottom or top? If GND is bottom, it looks like you have wire from GND to RESET pin, which will keep RESET at 0V and cause the device never to boot up.

      For some reason, bottom pin (GND still?) is connected via (58ohm?) resistor to ATtiny GND, this would limit the current to device and probably cause it not to work. Or maybe it’s not connected to the GND at all?

      I don’t see where zeners are connected on the bottom of the board. Actually I don’t know how your perfboard holes are connected to each other, if at all, so it’s impossible to check connections from the picture.

      No connections apart from VCC pin go to right side of ATTiny on top, do you use the same pins for D+ and D- as in my example? In that case, there should be connections there, too.

      To summarize, it’s hard to say anything from the picture, and also I’m not sure I would have the time to debug it, an electronics forum might have more eyes and people with lots of time at their hands.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.