基于密码的加密技术如何工作? [英] How does password-based encryption technically work?

查看:112
本文介绍了基于密码的加密技术如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一些数据和密码,我想加密数据,只能用正确的密码恢复。



如何这在技术上是如何工作的(即如何实现这一点)?我经常听到人们使用分拣加密,但是你如何基于密码呢?基于密码的加密如何工作?



一个例子是Mac OS X FileVault



谢谢。






如果您提供示例代码,最好在C,Objective-C或伪代码中。

解决方案

对于(对称)加密,您需要一个用于加密和解密的密钥。



通常,您提供的密码用作此键。由于各种安全原因,密码不是(而且通常不能,由于使用密码的要求)直接用作密钥。相反,密钥导出功能 用于生成密钥密码。



这就是加密密码必须长和相当随机的原因:否则生成的密钥只能来自可能密钥的一小部分,然后可以简单地说,所有这些都被尝试,因此强制加密。



关于代码示例,有几种可能性:




  • 查看加密库的源代码,例如 OpenSSL

  • 查看实现加密的程序的源代码,例如 GnuPG

  • google一些简单加密算法或一个关键派生函数的示例源代码,并尝试了解



这取决于你想要学习的东西。


Say I have some data and a password, and I want to encrypt the data in such a way that it can only be recovered with the right password.

How does this technically work (i.e. how to implement this)? I often hear people use bitshifting for encryption, but how do you base that on a password? How does password-based encryption work?

An example is Mac OS X FileVault

Thanks.


If you give sample code, preferably in C, Objective-C or pseudocode.

解决方案

For (symmetric) encryption you need a secret key for encryption and decryption.

Usually, the password you supply is used as the source of this key. For various security reasons, the password is not (and often cannot, due to requirements of the cipher used) directly used as the key. Instead, a key derivation function is used to generate the key from the password.

This is why passwords for encryption must be long and fairly random: Otherwise the resulting key will only come from a very small subset of possible keys, and these can then simply all be tried, thus brute-forcing the encryption.

As to code examples, there are several possibilities:

  • look at the source code of a crypto library, such as OpenSSL
  • look at the source code of a program that implements encryption, such as GnuPG
  • google some sample source code for a simple encryption algorithm, or a key derivation function, and try to understand it

This depends on what you want to learn.

这篇关于基于密码的加密技术如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆