我正在为用户密码部署经典的哈希保护.登录时提交的密码被加盐,散列,然后与数据库中已存储的散列进行比较.
但是不是使用PHP函数调用来比较现在的散列用户输入和存储的散列,而是在数据库中进行比较 - 更准确地说,使用一个WHERE子句(注意:在比较开始时,盐已经因各种原因而已知) ,但密码不是).
由于用户名是唯一的,因此以下查询有效地告知用户名+密码对是否匹配:
SELECT * FROM `users` WHERE `password`='$password_hash' AND `username`='$username';
Run Code Online (Sandbox Code Playgroud)
这种方法容易受到时间攻击吗?
编辑:SQL注入不是一个问题,它是照顾.
在使用AudioBufferSourceNode开始播放来自AudioBuffer的音频后,如何在预定时间(以毫秒为单位)后停止播放?我的设置很简单:
// create audio source
var source = audioCtx.createBufferSource();
// play audio from source
source.start();
Run Code Online (Sandbox Code Playgroud)
使用AudioBufferSourceNode.stop()我只能以秒为单位指定此持续时间,但由于某种原因,提供任何非整数将被评估为零,并使音频立即停止:
source.stop(0.25); // should be 250 milliseconds, but audio stops immediately
Run Code Online (Sandbox Code Playgroud)
setTimeout不够精确,偶尔出现抖动/漂移,特别是如果UI工作很多,或者其他计算正在其他地方执行.
setTimeout(function () {
source.stop(); // very inaccurate
}, 250);
Run Code Online (Sandbox Code Playgroud)
是否有一个简单的解决方案,在一定的毫秒数后停止播放音频,而不是像工作线程中的繁忙等待那样的黑客,或类似的?
使用Web Audio API,我希望将一个外部AudioNode连接到一个封装的子系统,该子系统由任意可变的内部AudioNodes动态链组成,因此,我需要一个节点作为固定入口点。
可以通过一个非常简单的AudioNode列表来表示外部节点与子系统之间的关系(彼此之间的每个后续节点从上到下连接,上述子系统以短划线开头):
externalNode
- input
- effectNode1
- effectNode2
- effectNode3
- outnode
externalNode
destination
Run Code Online (Sandbox Code Playgroud)
但是,Web Audio API中没有简单的传递节点。如果我想保持良好的性能,我将如何克服这个问题?我目前使用的是一个简单的GainNode,其gain.value设置为,1因此它不会影响输出,但是设置仍然意味着需要额外的处理工作。
另一种可能的设置是使用AnalyserNode,它可以使音频本身保持不变,但我不确定其性能或如何测量。
使用ReactJS的es6方法与类中的方法中的'this'关键字的上下文混淆
这给出了一个错误,无法获得未定义的引用
class AddItem extends React.Component {
constructor() {
super();
}
addIt(e) {
e.preventDefault();
let newItem = {
title: this.refs.title.value
}
this.refs.feedForm.reset();
this.props.addItem(newItem);
}
render() {
return (
<div>
<form ref="feedForm" onSubmit={this.addIt}>
<div className="input-group">
<span className="input-group-addon"><strong>Title:</strong></span>
<input ref="title" type="text" className="form-control" />
</div>
<button className="btn btn-success btn-block">Add Item</button>
</form>
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
但这似乎工作正常
class AddItem extends React.Component {
constructor() {
super();
this.addIt = function(e) {
e.preventDefault();
let newItem = {
title: this.refs.title.value
}
this.refs.feedForm.reset();
this.props.addItem(newItem);
}.bind(this)
}
render() {
return …Run Code Online (Sandbox Code Playgroud) 标题说明了一切.我有一个jquery序列化数据,如下所示:
tarid=value&tarname=value&sel=3
Run Code Online (Sandbox Code Playgroud)
我想将它转换为ArrayBuffer.之后,我还需要再次将其恢复原状.那我该怎么办呢?
我构建了一个接口,接受所有潜在的搜索条件,然后将其传递给将所有值放入服务URL的服务.是否可以遍历界面中的所有对象,我能够检索键和值吗?我最初写了一个很长的if ... else if ...陈述(下面的示例.)我不确定我是否会以最好的方式解决这个问题
接口:
export interface ILegislatorSearchCriteria {
all_legislators?: string;
in_office?: string; // true false
party?: string; // 'R', 'D', or 'I'
gender?: string; // 'M' or 'F'
state?: string; // Two letter code
...
}
Run Code Online (Sandbox Code Playgroud)
服务:
getLegislators(crit: ILegislatorSearchCriteria): Observable<ILegislator[]> {
let serviceUrl = this._legislatorUrl;
if (crit.all_legislators !== null) {
serviceUrl += '&all_legislators=' + crit.all_legislators;
} else if (crit.in_office !== null) {
serviceUrl += '&in_office=' + crit.all_legislators;
} else if (crit.party) {
serviceUrl += '&party=' + …Run Code Online (Sandbox Code Playgroud) 我通过$idURL 传递一个变量,并以表单形式加载数据,但是当我要验证表单时,$id无法识别该值.
function myfunction() {
$id = $this->uri->segment(4);
echo $id; //yes, print the value
$data_user = $this->admin_model->query_data_user($id);
$direccion = $data_user[0]->address;
$phone = $data_user[0]->phone;
$this->data['address'] = array(
'name' => 'address',
'id' => 'address',
'value' => $address,
'class' => 'input',
);
$this->data['phone'] = array(
'name' => 'phone',
'id' => 'phone',
'value' => $phone,
'class' => 'input',
);
echo $id; //yes, print the value
$this->form_validation->set_rules('address', 'Address', 'xss_clean|max_length[100]');
$this->form_validation->set_rules('phone', 'Phone', 'required|xss_clean|max_length[20]|is_natural_no_zero');
if ($this->form_validation->run() == true) {
echo $id; //here NOT …Run Code Online (Sandbox Code Playgroud) 在for循环中评论为:
//迭代数组并将每个元素追加为li
...如果我只是放入console.log(tags [x]),有一个闭包可以正常工作; 这表明封闭按预期工作.但是,当我把闭包应该包含的实际代码,即.this.displayImg(标签[X]); 它会抛出一个错误.当我点击li时,我得到:
Uncaught TypeError: this.displayImg is not a function
(anonymous function) @ script.js:49
Run Code Online (Sandbox Code Playgroud)
请告知我如何从那个地方访问this.displayImg.
var myGallery = (function () {
var s;
return {
settings: {
data: JSON.parse(data),
filter: document.getElementById("filter"),
gallery: document.getElementById("gallery")
},
init: function () {
// kick things off
s = this.settings;
// By default, call the fillImages function with 'all' tag
this.createFilters("all");
},
createFilters: function (tag) {
// Load the image data
// I made imgs global as I couldn't access it from …Run Code Online (Sandbox Code Playgroud) 我只是尝试一些简单的东西,比如只在handleSubmit函数中打印this.state.validForm,但我似乎无法访问this.state.validForm.首先我直接尝试使用此功能,但无济于事.我是新来的反应.
import React, { Component } from 'react';
import TextInput from './TextInput';
class RequestForm extends Component {
constructor(props) {
super(props);
this.state = {validForm : "false"};
this.getInfoForm = this.getInfoForm.bind(this);
}
getInfoForm() {
return this.state.validForm;
}
handleSubmit(event) {
event.preventDefault();
console.log('submit values are');
console.log(event.target.src.value);
console.log(event.target.email.value);
console.log(this.state.validForm);
console.log(this.getInfoForm());
}
render() {
return (
<form onSubmit={this.handleSubmit}>
<TextInput
uniqueName="email"
name="email"
text="Email Address"
required={true}
minCharacters={6}
validate="email"
errorMessage="Email is invalid"
emptyMessage="Email is required"
/>
<TextInput
text="User"
name="User src"
required={true}
minCharacters={3}
validate="notEmpty"
errorMessage="Name is invalid"
emptyMessage="Name is required"
/> …Run Code Online (Sandbox Code Playgroud) 在 TypeScript 中,我想要与逗号分隔的重复字符串不同的值:
this.Proid = this.ProductIdList.map(function (e) { return e.ProductId;}).join(',');
this.Proid = "2,5,2,3,3";
Run Code Online (Sandbox Code Playgroud)
我需要:
this.Proid = "2,5,3";
Run Code Online (Sandbox Code Playgroud) javascript ×5
angular ×2
php ×2
reactjs ×2
typescript ×2
arraybuffer ×1
codeigniter ×1
ecmascript-6 ×1
hash ×1
html5 ×1
login ×1
mysql ×1
object ×1
react-jsx ×1
security ×1
typed-arrays ×1