This fixes #41 by wrapping the String that holds the password in a new type, ZeroOnDrop, that zeroes the string inside when it's dropped. This means that a good portion of the code for zeroing disappears, which I think makes the code a bit more readable. It should also make it harder to forget to zero it. The ZeroOnDrop struct provides a method into_inner that returns the contains String by value, for the case where we actually want it.
@tov Thanks again for your help ! I've added you to the README.md. I've just waiting for the builds to finish, if it's all green I'll publish as version 4.0.5 on crates.io.
This fixes #41 by wrapping the
String
that holds the password in a new type,ZeroOnDrop
, that zeroes the string inside when it's dropped. This means that a good portion of the code for zeroing disappears, which I think makes the code a bit more readable. It should also make it harder to forget to zero it. TheZeroOnDrop
struct provides a methodinto_inner
that returns the containsString
by value, for the case where we actually want it.