NSDictionary 中的 32 位无符号整数

发布于 2024-10-10 08:55:45 字数 235 浏览 7 评论 0原文

我正在开发 LiveJournal.com 客户端,我有一个问题。请你解释一下这是什么意思吗?

标量 当安全性为 usemask 时相关。一个 32 位无符号整数,表示允许用户的哪些朋友组查看此帖子。打开位 0 以允许任何定义的好友读取它。否则,为每个应该允许读取它的朋友组打开位 1-30。位 31 被保留。

例如,如果我想查看 id=6 的组,我需要在 NSMutableDictionary 中添加什么?我不明白...

I am developing LiveJournal.com client and i have one question. Can u, please, explain what does it mean?

scalar Relevant when security is usemask. A 32-bit unsigned integer representing which of the user's groups of friends are allowed to view this post. Turn bit 0 on to allow any defined friend to read it. Otherwise, turn bit 1-30 on for every friend group that should be allowed to read it. Bit 31 is reserved.

What am i need to add in NSMutableDictionary if i want to see, for example, group with id=6? I don't understand...

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

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

发布评论

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

评论(1

忘年祭陌 2024-10-17 08:55:45

安全实现的工作原理是授权或禁止一组朋友阅读日记/文本。

假设最多有 30 个可能的组,因为 bit-0 是特定的,而 bit-31 是保留的。

安全性采用unsigned int编码,即32位,其中bit0到bit31具有特殊含义。

  • LSb,bit0,如果设置为1,则允许任何朋友进行读取访问。
  • 如果 bit0 为 0,则表示检查接下来的 30 位(bit1 到 30),以查看组 i(来自位 i ) 具有读取权限(位设置为 1)或没有读取权限(位设置为 0)。

unsigned int 可以表示为

  bit 31                     bit 0
  v                              v
  bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

十进制值 11(0...01011 或 8+3),

  00000000000000000000000000001011

其中位 0、1 和 3 设置为 1,其他位设置为 1被设置为 0。

因此,要检查朋友是否可以访问日记,请获取日记访问位,例如

  11000000000000000000000000001011

您看到第一位是 1,因此所有组(所有朋友)都可以授权。

如果访问的

  11000000000000000000000000001010

第一位是0,那么您必须根据上面的访问检查组号。假设组号为 1,您对照上面的访问权限进行检查

  11000000000000000000000000001010
                                1
                                ^
                        group one

,您会发现组 1 已获得授权。如果您希望

  11000000000000000000000000001000

组 1 未获得授权。

对于第3组和第30组,也已授权访问:

  11000000000000000000000000001000
   *                          *

(MSb.bit31设置为1,但其值是保留的,因此您不必打扰它的值)

The security implementation works by authorizing or no a group of friends to read a journal/text.

This assume there is a maximum of 30 possible groups, as bit-0 is specific, and bit-31 is reserved.

The security is coded on an unsigned int, meaning 32 bits, of which bit0 to bit31 have a special meaning.

  • the LSb, bit0, if set to 1 allows any friend the read access.
  • if bit0 is 0, it means that the next 30 bits, bit1 to 30, are checked to see if the group i (from bit i) has read access (bit set to 1) or no (bit set to 0).

An unsigned int can be represented as

  bit 31                     bit 0
  v                              v
  bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

for instance the decimal value of 11 (0...01011, or 8+3) is represented as

  00000000000000000000000000001011

where bit 0, 1 and 3 are set to 1, the others are set to 0.

So, to check if a friend has access to a journal, take the journal access bits, for instance

  11000000000000000000000000001011

you see that the first bit is 1, so all groups (all friends) are authorized.

If the access would be

  11000000000000000000000000001010

the first bit is 0, so you have to check the group number against the access above. Say the group number is 1, you check against the access above

  11000000000000000000000000001010
                                1
                                ^
                        group one

and you see that the group 1 is authorized. If you would have

  11000000000000000000000000001000

the group 1 is not authorized.

For groups 3 and 30, the access is also authorized:

  11000000000000000000000000001000
   *                          *

(The MSb. bit31 is set to 1, but its value is reserved, so you shouldn't bother its value)

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