小编Sap*_*ana的帖子

如何在python中生成唯一的身份验证令牌?

我正在尝试为我的 android 应用程序在烧瓶中编写一个基于令牌的身份验证。为此,我需要一个唯一的令牌,我可以使用它来验证用户。

它的危险库提供了一个 JSONWebSignatureSerializer 函数,我可以使用它来创建 JWT 令牌。所以我的第一个问题是,将 JWT 用于基于移动的身份验证是否安全?

其次,我对 django rest 框架如何生成其令牌进行了一些研究。

def generate_key(self):
    return binascii.hexlify(os.urandom(20)).decode()  
Run Code Online (Sandbox Code Playgroud)

这个令牌是唯一的还是只是一个随机的?我应该使用哪一个进行基于移动的身份验证?

在 python 中为移动应用程序生成唯一令牌的基本方法是什么?

python django flask python-3.x

14
推荐指数
3
解决办法
3万
查看次数

我什么时候需要使用super(props)将prop传递给react组件的构造函数?

很多时候我们在构造函数中发送props但是我们从不在构造函数中的任何地方使用this.props,所以为什么需要传递它以及何时需要这样做.

 class App extends React.Component {

      constructor(props) {
        super(props);    // When do we need to send props to the constructor
        this.state = {
           data: 'Initial data...'
        }
        this.updateState = this.updateState.bind(this);
      };

      updateState(e) {
          this.setState({data: e.target.value});
      }

      render() {
        return (
           <div>
             <input type = "text" value = {this.state.data} 
              onChange = {this.updateState} />
             <h4>{this.state.data}</h4>
          </div>
        );
      }

   }
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6 reactjs

5
推荐指数
1
解决办法
1887
查看次数

标签 统计

django ×1

ecmascript-6 ×1

flask ×1

javascript ×1

python ×1

python-3.x ×1

reactjs ×1