Question:
JAVA code (OR any for that matter) that requires password to unlock contents on a flash drive?
Kobe Young
2018-05-29 00:46:11 UTC
I used know a little bit about coding, however that knowledge has escaped me.
I know a simple way to "encrypt" a folder, how ever I would like to make it where it would ask for a password or code asking for the year. If the correct year or any year above is entered it will unlock. But if the incorrect year is entered timer will activate for the number of years until the correct year.

Example: Target year: 2118
"What is the current Year: "
User entered 2046
Timer for 72 years starts
Once the 72 years is over the password may be entered again
Three answers:
NerdyKid1101
2018-05-29 21:40:58 UTC
Veracrypt is good, BitLocker is good, there are lots of encrypting software.
?
2018-05-29 20:43:01 UTC
Zip up all the data and then encrypt it using whatever encrypting algorithm you want.



A simple encryption algorithm that would be pretty reliable is one-time pad encryption. If you use a good cryptographically secure random number generator, it would be theoretically impossible to crack yet would be incredibly easy to implement. You'd need somewhere to store your pad, though, which is your key, so you might need a second flash drive in order to unlock the one you have, and unlocking could take a large amount of time.



It will be difficult to prevent the user from entering a second password and lock them out. That state would need to be stored somewhere to persist to the next time you run the program. If you saved the state to the hard drive, they could just delete the file saving the state.



It might be possible if you require the user to sync to a website in order to verify the password. This will require you to setup a webserver and understand basic web security such that someone couldn't simply sniff your connection and steal your passwords and such.



Although, a benefit of doing it through the web is you could store your one-time pad there and then generate new one-time pads every time you unlock it, which would not require a second flash drive and would be much more secure.



The downside would be that you would not be able to unlock the flash drive without an internet connection.
husoski
2018-05-29 01:53:53 UTC
You can't set a timer that will last beyond the end of the program run; not without assistance from (and usually permission from) the operating system.



You'll definitely need permission to get that timer to persist over an operating system reboot. (Show me a computer that has been continuously running for 72 years... sheesh!)



One way to simulate such a thing is to write a file to the USB drive that has all the pending events (encrypted, of course) and depend on the user not spoofing the operating system's current date. Of course, all a user has to do is back up the drive in advance and try a guess/restore loop until a good password is discovered.



Is there a serious use for this weird feature? I can't think of one.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...