Html 如何在coldfusion中将密码作为哈希插入Ms SQL?
我正在创建一个保存用户注册的表单。我想将密码作为哈希或md5插入数据库 这是我的html表单,包含少量coldfusion代码:Html 如何在coldfusion中将密码作为哈希插入Ms SQL?,html,css,sql-server,coldfusion,Html,Css,Sql Server,Coldfusion,我正在创建一个保存用户注册的表单。我想将密码作为哈希或md5插入数据库 这是我的html表单,包含少量coldfusion代码: <form id="myForm" class="ui form segment" method="post" action="registeraction.cfm"> <p>Let's go ahead and get you signed up.</p> <div class="f
<form id="myForm" class="ui form segment" method="post" action="registeraction.cfm">
<p>Let's go ahead and get you signed up.</p>
<div class="field">
<div class="field">
<label>Name</label>
<input placeholder="Name" name="name" type="text">
</div>
</div>
<div class="field">
<div class="field">
<label>Email</label>
<input placeholder="Email" name="email" type="email">
</div>
</div>
<div class="field">
<div class="field">
<label>Password</label>
<input placeholder="Password" name="password" type="password">
</div>
</div>
<input class="ui blue submit button" type="Submit" value="Submit">
</form>
这是registeraction.cfm中的代码:
<!--- Insert the new record --->
<cfinsert datasource="mydatasource" tablename="Users">
<h1>User Added</h1>
<cfoutput> You have added #Form.name# #Form.email# to the testdb database.
</cfoutput>
对于众所周知的哈希,可以使用SQL Server内置函数HASHBYTES-它返回VARBINARY 例如:
在dbo.table中插入密码值HASHBYTES'MD5','plaintext'对于众所周知的哈希,您可以使用SQL Server内置函数HASHBYTES-它返回VARBINARY 例如:
在dbo.table中插入密码值HASHBYTES'MD5','plaintext'我认为这应该适合您。在registeraction.cfm中,只需创建哈希并将其存储在form.password中,我建议对任何业务逻辑使用CFC,而仅对表示使用cfm
<cfset form.password = Hash(Form.password, "SHA") >
<!--- Insert the new record --->
<cfinsert datasource="mydatasource" tablename="Users">
<h1>User Added</h1>
<cfoutput> You have added #Form.name# #Form.email# to the testdb database.
</cfoutput>
我想这应该对你有用。在registeraction.cfm中,只需创建哈希并将其存储在form.password中,我建议对任何业务逻辑使用CFC,而仅对表示使用cfm
<cfset form.password = Hash(Form.password, "SHA") >
<!--- Insert the new record --->
<cfinsert datasource="mydatasource" tablename="Users">
<h1>User Added</h1>
<cfoutput> You have added #Form.name# #Form.email# to the testdb database.
</cfoutput>
您应该避免使用MD5,因为它被认为是一种弱算法。见:
此外,你不应该只是散列密码,你应该结合明文密码与盐。有关更多信息,请参阅:您应该避免使用MD5,因为它被认为是一种弱算法。见:
此外,你不应该只是散列密码,你应该结合明文密码与盐。有关更多信息,请参阅:谢谢。工作起来像个魔咒谢谢你。就像下面@pete freitag建议的charmAs一样-请重新考虑一个更好的散列算法。为此,我在SQL Server中使用bcrypt作为CLR。正如下面@pete freitag所建议的,请重新考虑更好的哈希算法。为此,我在SQLServer中将bcrypt用作CLR。