TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Encrypted File as a Login Method

2 点作者 anbardoi大约 1 年前
I&#x27;m developing an anonymous blogging website that exemplifies user privacy and instead of going the ol&#x27; tried-and-true route of requiring an email&#x2F;password for account creation&#x2F;login, I want to do this:<p>Generate a file containing a random string of text, then encrypt it<p>Calculate the sha256 checksum of the encrypted file and store it in a database. Then provide the file and the decryption key to the user for download.<p>When the user wants to login, they upload that file to my server in a buffer, where the sha256 is calculated and checked against the database. If it matches, user gains access to their account data, associated with the checksum. If it doesnt, the file is rejected. Either way, the encrypted file is deleted after checking.<p>I think this would be really secure because if my server is compromised, the only thing an attacker would have is sha256 checksums as user identifiers. I know there&#x27;s probably hashing&#x2F;file-handling attack vectors, as well as file-collision scenarios(although rare, still possible)<p>Are there any additional considerations I should take into account with this project? Also, security QA&#x27;s as recovery in case they lose their file.

5 条评论

hcta大约 1 年前
1. what you&#x27;re describing as a &quot;file&quot; is really no different from a &quot;password&quot;. I assume you&#x27;re choosing to call it a &quot;file&quot; because you&#x27;re picturing generating some huge blob, but a randomly generated password doesn&#x27;t need to be very long to be effectively uncrackable, so I think you&#x27;re proposing wasting time&#x2F;bandwidth for no added security.<p>2. You should always &quot;salt&quot; stored password hashes. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Salt_(cryptography)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Salt_(cryptography)</a><p>3. I think you should look at resources like <a href="https:&#x2F;&#x2F;www.vice.com&#x2F;en&#x2F;article&#x2F;wnx8nq&#x2F;why-you-dont-roll-your-own-crypto" rel="nofollow">https:&#x2F;&#x2F;www.vice.com&#x2F;en&#x2F;article&#x2F;wnx8nq&#x2F;why-you-dont-roll-you...</a> <a href="https:&#x2F;&#x2F;security.stackexchange.com&#x2F;questions&#x2F;18197&#x2F;why-shouldnt-we-roll-our-own" rel="nofollow">https:&#x2F;&#x2F;security.stackexchange.com&#x2F;questions&#x2F;18197&#x2F;why-shoul...</a> <a href="https:&#x2F;&#x2F;www.infosecinstitute.com&#x2F;resources&#x2F;cryptography&#x2F;the-dangers-of-rolling-your-own-encryption&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.infosecinstitute.com&#x2F;resources&#x2F;cryptography&#x2F;the-...</a> to examine the arguments against trying to develop your own security schemes as someone with less experience in this space.
评论 #40087856 未加载
gus_massa大约 1 年前
&gt; <i>Generate a file containing a random string of text, then encrypt it.</i><p>If it&#x27;s random, why do you need to encript it?<p>&gt; <i>When the user wants to login, they upload that file to my server in a buffer, where the sha256 is calculated and checked against the database. [...] Either way, the encrypted file is deleted after checking.</i><p>This is exactly like the standard method to login users. You don&#x27;t store the password in the server, you only stored a hash of the password. Why are you proposing to use sha256 instead of bcrypt or scrypt?
评论 #40094938 未加载
foldr大约 1 年前
Storing the password in a file isn&#x27;t too bad in principle, but it opens the door to user error. It&#x27;s easy to accidentally upload a file containing a password to the wrong place.
评论 #40087970 未加载
pestatije大约 1 年前
your not considering users device being compromised, nor usability...plus nowadays, to &quot;exemplify user privacy&quot; is not to reinvent the infrastructure but to demonstrate users data is not sold on their back and non-collusion with secret agencies &#x2F; law enforcement
评论 #40087937 未加载
1oooqooq大约 1 年前
it can be much simpler. just use s random number.<p>see how mullvad does it