If you have a coded book, do you have to read it to them?
Obviously you will be detained if you try and prevent lawful execution of a search warrant. But its kind of a false equivalency saw that not providing a passcode is the same.
From the Justice John Paul Stevens dissent from Justice John Paul Stevens (487 U.S. 201)
A defendant can be compelled to produce material evidence
that is incriminating. Fingerprints, blood samples, voice
exemplars, handwriting specimens, or other items of
physical evidence may be extracted from a defendant
against his will. But can he be compelled to use his
mind to assist the prosecution in convicting him of a
crime? I think not. He may in some cases be forced to
surrender a key to a strongbox containing incriminating
documents, but I do not believe he can be compelled to
reveal the combination to his wall safe — by word or
deed.
This confirmed in UNITED STATES v. HUBBELL. That being said it has been challenged, and ruled on both sides do to the somewhat ambiguous framing.
https://www.law.cornell.edu/supremecourt/text/487/201
https://caselaw.findlaw.com/us-supreme-court/530/27.html