惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
Stack Overflow Blog
Stack Overflow Blog
D
DataBreaches.Net
罗磊的独立博客
博客园 - 司徒正美
Last Week in AI
Last Week in AI
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
宝玉的分享
宝玉的分享
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
小众软件
小众软件
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
B
Blog
博客园 - 【当耐特】
V
V2EX
Apple Machine Learning Research
Apple Machine Learning Research
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - 农民伯伯

【读书笔记】达利欧 - 《原则:应对变化中的世界秩序》 【读书笔记】余华 - 活着 Mixin 工作原理 公链 - 达世币(Dash) 公链 - 比原链(Bytom) 公链 - Horizen 公链 - 以太坊(Ethereum) 公链 - Filecoin 公链 - EOS 公链 - 门罗币(Monero) 公链 - 比特币(Bitcoin) Git 简易手册 三大运营商手机号段发布时间汇总 中英文混排指南 - 简化版 iOS Share Extension 自定义分享界面 Mixin Messenger 源码解读 1 — — WCDB Swift 2018 年流水账 区块链代币(Token)笔记 — — 术语 【Swift 4.0】扩展 WCDB 支持 SQL 语句
【Swift 4.2】uuid 取 hashCode(与 Java/Go/Kotlin 一致) -...
农民伯伯 · 2019-02-25 · via 博客园 - 农民伯伯
extension String {

    func hashCode() -> Int32 {
        let components = self.split(separator: "-")

        var mostSigBits = Int64(components[0], radix: 16)!
        mostSigBits <<= 16

        let c1 = Int64(components[1], radix: 16)!
        mostSigBits |= c1
        mostSigBits <<= 16
        let c2 = Int64(components[2], radix: 16)!
        mostSigBits |= c2

        var leastSigBits = Int64(components[3], radix: 16)!
        leastSigBits <<= 48
        let c4 = Int64(components[4], radix: 16)!
        leastSigBits |= c4

        let hilo = mostSigBits ^ leastSigBits

        return Int32(truncatingIfNeeded: hilo>>32) ^ Int32(truncatingIfNeeded: hilo)
    }
}

在 Playground 里面用 "c2ab81d4-2226-4d0c-a49a-dc59b34f7972" 测试输出 "-145200653"