如何让 Perl crypt 加密超过 8 个字符? [英] How to get Perl crypt to encrypt more than 8 characters?

查看:66
本文介绍了如何让 Perl crypt 加密超过 8 个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用 Perl crypt 函数时,只有前 8 个字符被加密.有没有办法让它使用更多的字符?

Only the first 8 characters is encrypted when the Perl crypt function is used. Is there a way to get it to use more characters?

举个例子:

$crypted_password = crypt ("PassWord", "SALT");

$crypted_password = crypt ("PassWord123", "SALT");

返回完全相同的结果.$crypted_pa​​ssword 具有完全相同的值.

returns exactly the same result. $crypted_password has exactly the same value.

很想使用 crypt,因为它是一些不可逆加密的快速简便的解决方案,但这个限制并没有使它对任何严肃的事情都有用.

Would love to use crypt because it is a quick and easy solution to some none reversible encryption but this limit does not make it useful for anything serious.

推荐答案

引自 文档:

传统上结果是一个 13 个字节的字符串:salt 的前两个字节,然后是集合 [./0-9A-Za-z] 中的 11 个字节,并且只有第一个字节八字节的 PLAINTEXT 很重要.但是替代散列方案(如 MD5)、更高级别的安全方案(如 C2)以及在非 Unix 平台上的实现可能会产生不同的字符串.

Traditionally the result is a string of 13 bytes: two first bytes of the salt, followed by 11 bytes from the set [./0-9A-Za-z], and only the first eight bytes of PLAINTEXT mattered. But alternative hashing schemes (like MD5), higher level security schemes (like C2), and implementations on non-Unix platforms may produce different strings.

所以 crypt 的确切返回值是依赖于系统的,但它通常使用一种只查看密码前 8 个字节的算法.这两件事结合起来使它成为便携式密码加密的一个糟糕选择.如果您使用的系统具有更强大的加密例程,并且不要尝试在不兼容的系统上检查这些密码,那没问题.但听起来您正在使用带有旧的糟糕的 DES 例程的操作系统.

So the exact return value of crypt is system dependent, but it often uses an algorithm that only looks at the first 8 byte of the password. These two things combined make it a poor choice for portable password encryption. If you're using a system with a stronger encryption routine and don't try to check those passwords on incompatible systems, you're fine. But it sounds like you're using an OS with the old crappy DES routine.

因此,更好的选择是使用 CPAN 之外的模块,以可预测、更安全的方式进行加密.

So a better option is to use a module off of CPAN that does the encryption in a predictable, more secure way.

一些搜索提供了一些有前途的选项(我没有使用过,也不能推荐一个;我只是在 metacpan 上寻找有希望的关键字):

Some searching gives a few promising looking options (That I haven't used and can't recommend one over another; I just looked for promising keywords on metacpan):

这篇关于如何让 Perl crypt 加密超过 8 个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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