使用 sha256 响应本机
react native using sha256
我正在尝试使用 this react-native 库来进行 sha256 散列。这是我的代码:
import React, {Component} from 'react'
import { AppRegistry, Text, View} from 'react-native'
import {sha256} from 'react-native-sha256'
export default class CyrptoTest extends Component {
constructor(props){
super(props)
}
componentDidMount(){
sha256("test").then(hash => {
console.log(hash)
})
}
render(){
return(
<View style={{padding:30}}>
<Text>this is CryptoTest 1</Text>
</View>
)
}
}
我收到此错误:undefined is not an object (evaluating 'sha256lib.sha256')
我不知道这是为什么或如何解决这个问题,感谢任何帮助,谢谢
PS:
在我做任何这些之前,我首先在命令行中 运行 这个:
yarn add react-native-sha256
react-native link
还有 运行 我的 mac 模拟器中的应用程序,我这样做:
react-native start
react-native run-ios
我遇到了同样的问题,在我的例子中,我使用的是设备的 react native cli 调试服务器主机和端口,它通过 ./gradlew clean 解决并在 phone 上重新编译应用程序。
我正在尝试使用 this react-native 库来进行 sha256 散列。这是我的代码:
import React, {Component} from 'react'
import { AppRegistry, Text, View} from 'react-native'
import {sha256} from 'react-native-sha256'
export default class CyrptoTest extends Component {
constructor(props){
super(props)
}
componentDidMount(){
sha256("test").then(hash => {
console.log(hash)
})
}
render(){
return(
<View style={{padding:30}}>
<Text>this is CryptoTest 1</Text>
</View>
)
}
}
我收到此错误:undefined is not an object (evaluating 'sha256lib.sha256')
我不知道这是为什么或如何解决这个问题,感谢任何帮助,谢谢
PS: 在我做任何这些之前,我首先在命令行中 运行 这个:
yarn add react-native-sha256
react-native link
还有 运行 我的 mac 模拟器中的应用程序,我这样做:
react-native start
react-native run-ios
我遇到了同样的问题,在我的例子中,我使用的是设备的 react native cli 调试服务器主机和端口,它通过 ./gradlew clean 解决并在 phone 上重新编译应用程序。