为 iPhone 应用程序生成 5 个字符的唯一密钥

发布于 2024-10-19 09:44:07 字数 505 浏览 0 评论 0原文

我正在开发一个 iPhone 应用程序,我需要为每个用户分配一个 5 个字符的唯一密钥(由整数和字母组成),例如 whoisHere 和 pmesssenger 应用程序。

问题是密钥应该是普遍唯一的,每两个用户永远不能拥有相同的密钥。

我现在收集的信息是:

1-我可以使用 iphone uid 或 CFUUID 类在本地生成密钥,但我不完全了解如何成功转换为 5 个字符的唯一密钥。

2-我可以使密钥的生成全局化,例如,应用程序应连接到服务器以获取唯一的密钥。

另一方面,我希望用户即使更换设备也能保留UID,例如根据pmessenger应用程序网站,用户可以保留UID。

“如果您更换手机,您可以保留您的 PMiD... 为此,您只需从旧手机的备份中恢复新手机...PMiD 将转移到新手机,并且如果您出售,请不要忘记从旧手机中卸载 pMessenger您的旧手机,而新用户下载 pMessenger 他将获得完全不同的 PMiD“

那么,我怎样才能做到这一点?提前致谢。

i am developing an iphone app , i need to assign every user with a 5 characters unique key ( consisting of integers and alphabets ) like whoisHere and pmesssenger applications .

the problem is that the key should be universally unique , every two user shall never have the same key.

the information i collected up now is that :

1- i can use the iphone uid or CFUUID Class to generate key locally , but i'm not quit understand how to converted successfully to 5 characters unique key .

2- i can make the generation of the key global , for example , the app shall connect to a server to get unique key .

in the other hand , i want the user to keep the Uid even he/she changes the device , for example according to pmessenger application website , the user can keep the uid.

" you can keep your PMiD if you change phones...
In order to do that, you only have to restore your new phone from a backup of your old phone... The PMiD will be transfered to the new phone, and don't forget to uninstall pMessenger from the old phone, if you sell your old phone, and the new user download pMessenger he will get a completely different PMiD "

so , how can i possibly do that ? thanks in advance .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧伤还要旧人安 2024-10-26 09:44:07

是否有特定原因导致唯一密钥必须为 5 个字符?就像 Marc B 所说的,如果你连续分配它们,就很容易预测......

我建议在本地生成密钥。我的建议是:在本地转换 UID,并将其存储在云服务器(例如 MySQL 数据库)中,与设备的 UID 位于同一行。然后,当应用程序启动时,它可以在数据库中检查设备的 UID 是否正在使用,如果是,则使用关联的唯一字符代码。

换句话说,如果应用程序不知道已经创建的 ID,则很难创建唯一的 ID。在线数据库可以解决这个问题。

Is there a specific reason why the unique key has to be 5 characters? Like Marc B said, it would be easy to predict if you assigned them consecutively...

I would suggest generating the key locally. Here's my suggestion: convert the UID locally, and store it in a cloud server (like a MySQL database, for example), in the same row as the device's UID. Then, when the app starts, it can check in the database whether or not the device's UID is being used, if so, it uses the associated unique character code.

In other words, it's difficult for the app to make a unique ID if it's not aware of the ones that have already been created. An online database could solve that problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文