Swift 是否可以向Firebase中的子级添加密码?
我正在制作一个有频道的房间,用户可以加入并创建频道。但是,我希望用户可以选择向他们创建的频道添加密码。现在我想知道是否有可能在Firebase中添加一个加密的密码。当然,一个选项是像普通值一样在Firebase中以字符串形式上载密码,但这是任何人都可以读取的(因为.read规则表示为true)。这样,任何人都可以看到密码,这不是我想要的。所以我的问题是:这可能吗?如果可能,怎么可能?下面是一些可能有帮助的代码 创建通道iAction功能:Swift 是否可以向Firebase中的子级添加密码?,swift,firebase,firebase-realtime-database,firebase-authentication,firebase-security,Swift,Firebase,Firebase Realtime Database,Firebase Authentication,Firebase Security,我正在制作一个有频道的房间,用户可以加入并创建频道。但是,我希望用户可以选择向他们创建的频道添加密码。现在我想知道是否有可能在Firebase中添加一个加密的密码。当然,一个选项是像普通值一样在Firebase中以字符串形式上载密码,但这是任何人都可以读取的(因为.read规则表示为true)。这样,任何人都可以看到密码,这不是我想要的。所以我的问题是:这可能吗?如果可能,怎么可能?下面是一些可能有帮助的代码 创建通道iAction功能: @IBAction func createChannel
@IBAction func createChannel(_ sender: AnyObject) {
if let name = newChannelTextField?.text {
let newChannelRef = channelRef.childByAutoId()
let channelItem = [
"name": name
]
newChannelRef.setValue(channelItem)
}
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
if indexPath.section == Section.currentChannelsSection.rawValue
{
if searchController.isActive && searchController.searchBar.text != ""
{
let channel = filteredChannels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
else
{
let channel = channels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
}
}
Channel.swift:
internal class Channel {
internal let id: String
internal let name: String
init(id: String, name: String) {
self.id = id
self.name = name
}
}
是否选择了单元格功能:
@IBAction func createChannel(_ sender: AnyObject) {
if let name = newChannelTextField?.text {
let newChannelRef = channelRef.childByAutoId()
let channelItem = [
"name": name
]
newChannelRef.setValue(channelItem)
}
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
{
if indexPath.section == Section.currentChannelsSection.rawValue
{
if searchController.isActive && searchController.searchBar.text != ""
{
let channel = filteredChannels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
else
{
let channel = channels[(indexPath as NSIndexPath).row]
sendStatisticsToChannel(channel: channel)
}
}
}
否,除非您有服务器端来检查密码或在Firebase规则中公开密码。原因是为了检查用户输入的密码是否正确,必须对照实际密码进行检查。如果他们可以检查实际密码,那么他们就可以开始阅读。加密也是如此。如果一切都在客户端完成,则可能会有人逆转此过程。好的,谢谢。你知道如何在设备上实现这一点吗?有加密的扩展吗?非常感谢。我不确定您使用的是什么设备,但如果您的加密算法在用户的设备上,很可能会被破坏。您需要一台服务器来使用加密或密码。你考虑过另一种方法吗?