用于解密 DES 加密的 PHP 类或方法

发布于 2024-07-08 10:31:13 字数 55 浏览 6 评论 0 原文

DES 加密称为“单向加密”还是“双向加密”? 是否有 PHP 类或方法来解密 DES 加密?

Are DES Encryption called "One Way Encryption" or "two way Encryption" ?
Are there a PHP class or method to decrypt the DES Encryption ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

喜爱皱眉﹌ 2024-07-15 10:31:13

php crypt 函数是一个单向哈希函数,如果你想能够解密,请采取查看支持mcrypt扩展://www.php.net/manual/en/mcrypt.ciphers.php" rel="nofollow noreferrer">一系列算法

The php crypt function is a one-way hashing function, if you want to be able to decrypt, take a look at the mcrypt extension which supports a range of algorithms

冷夜 2024-07-15 10:31:13

应该指出的是,围绕 DES 算法存在(而且一直存在)问题。 它已经广泛使用了很长一段时间,但由于它最初只指定了 56 位密钥,因此目前它对于任何重要用途是否足够安全值得怀疑。 三重 DES 通常更好,但也存在一些已知的理论攻击。 如果您可以选择密码,则可能需要查看 AES

It should be noted that there are (and have always been) questions surrounding the DES algorithm. It's been widely in use for a long time, but since it was originally specified with only a 56 bit key, it's questionable whether it's secure enough for any important uses at this point. Triple DES is generally better, but there are some known theoretical attacks. If you have a choice of cipher, you might want to look at AES instead.

风和你 2024-07-15 10:31:13

DES 可以逆转,因此它是一种双向加密(如果您是这么想的话)。

DES 是一种众所周知的加密标准,因此它也应该在 PHP 中可用。

DES can be reversed, so it's a two-way encryption (if you meant that).

DES is a pretty well known encryption standard so it should be available in PHP too.

她如夕阳 2024-07-15 10:31:13

单向加密是一种散列的安全形式:明文被更改为明显随机的数据序列,通常具有固定长度,这样原始明文就可以被加密。 (理论上)如果不使用蛮力就无法检索。

双向加密可逆加密是我们通常所说的“加密”一词的含义:明文被转换为表面上随机的数据,但在一种依赖于允许检索原始明文的“密钥”的方法。

DES 是一种可逆加密形式,按照当今的标准来看,它的强度相对较弱,因为它依赖于 56 位密钥(14 个十六进制字符)。 它已被 3DES 或三重 DES 取代,后者本质上是相同的算法,但密钥更长。

您没有提及您的应用程序,但如果您只需要比较数据而不是检索数据,则散列被认为更安全。 例如,您可以存储散列密码; 然后,当用户进行身份验证时,对输入的文本执行相同的哈希,并将其与存储的哈希值进行比较。 如果它们匹配,则输入了正确的密码。

散列的一个显着优点是您不需要存储解密密钥。

One-way encryption is a secure form of hashing: the plaintext is changed into an apparently random sequence of data, often of fixed length, in such a way that the original plaintext (theoretically) cannot be retrieved without a brute-force effort.

Two-way encryption, or reversible encryption is what we normally mean by the term encryption: the plaintext is transformed into apparently random data, but in a way that relies on a "key" that allows the original plaintext to be retrieved.

DES is a form of reversible encryption that is relatively weak by today's standards, as it relies on a 56-bit key (14 hex characters). It has been superseded by 3DES, or triple-DES, which is essentially the same algorithm with a longer key.

You don't mention your application, but if you need only to compare the data and not retrieve it, hashing is considered more secure. For example, you can store hashed passwords; then, when a user authenticates, perform the same hash on the entered text and compare it with the stored hashed value. If they match, the correct password was entered.

A significant advantage to hashing is that you don't need to store a decryption key.

不奢求什么 2024-07-15 10:31:13

我不熟悉“单向加密”或“双向加密”术语。 有一个术语“一次性密码”(与 DES 完全无关),并且有“对称”和“非对称”加密算法,意思是使用相同的密钥进行加密和解密(对称)还是使用一组两个不同的密钥一个用于加密,另一个用于解密(非对称)。 DES 是一种对称算法。 至于 PHP, crypt() 正在做这项工作:

https://www.php.net/crypt< /a>

I am not familiar with the "one way encryption" or "two way encryption" terms. There is a term "one time password" (totally irrelevant for DES), and there are "symmetric" and "assymetric" encryption algorithms, meaning whether the same key is used for encryption and decryption (symmetric) or a set of two different keys is used one for encryption and another for decryption (assymetric). DES is a symmetric algorithm. As for PHP, crypt() since to be doing the job:

https://www.php.net/crypt

真心难拥有 2024-07-15 10:31:13

我认为你可能指的是单向函数 [1]。 在密码学中,人们区分对称密码学和非对称密码学。 对称加密使用相同的密钥来加密和解密(DES 是对称的)。 非对称加密用于密钥交换,公钥用于加密消息,而私钥用于解密。 非对称加密的一个例子是 AES [2]。 非对称加密使用单向函数。

[1] http://en.wikipedia.org/wiki/One-way_function
[2] http://en.wikipedia.org/wiki/AES

I Think you probably mean a one-way function [1]. In cryptography one distinguishes between symmetric and asymmetric cryptography. Symmetric cryptography uses the same key to encrypt and decrypt (DES is symmetric). Asymmetric Cryptography is used for key exchange and a public key is used to encrypt the message, while the private key is used to decrypt it. An example of Asymmetric Cryptography is AES [2]. Asymmetric cryptography uses one way functions.

[1] http://en.wikipedia.org/wiki/One-way_function
[2] http://en.wikipedia.org/wiki/AES

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文