Programming Molecular Devices using Nucleic Acid Hairpins