We study the closure in the Hardy space or the disk algebra of algebras generated by two bounded functions, of which one is a finite Blaschke product. We give necessary and sufficient conditions for density or finite codimension of such algebras. The conditions are expressed in terms of the inner part of a function which is explicitly derived from each pair of generators. Our results are based on identifying z-invariant subspaces included in the closure of the algebra. Versions of these results for the case of the disk algebra are given.