如何使用php创建一个unix密码哈希值 [英] How do I create a unix password hash with php

查看:169
本文介绍了如何使用php创建一个unix密码哈希值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用php脚本安全地创建系统用户,因此,我希望能够使用php脚本来散列密码,以便他们的密码在bash历史记录中无处显示。 p>

如何获取一个字符串,并对其进行哈希以便它是一个unix密码哈希?

  $ UX_PW = some_function('my_password'); 
exec(useradd -p $ UX_PW newusername);


解决方案

crypt()实现UNIX密码哈希。

http://us.php.net/manual/en/function.crypt.php

I'm trying to create system users with a php script securely, In that, I'd like to be able to hash the password with the php script, so that their password shows up nowhere in the bash history.

How to I take a string, and hash it so it is a unix password hash?

$UX_PW = some_function('my_password');
exec("useradd -p $UX_PW newusername");

解决方案

It's crypt() that implements the UNIX password hashing.
http://us.php.net/manual/en/function.crypt.php

这篇关于如何使用php创建一个unix密码哈希值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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