PulseCanvas / app · pulsecanvas.ai / Sources / PulseCanvas / PulseCanvasMCPProjects.swift
| 1 | #if os(macOS) && DIRECT_BUILD && !STORE_BUILD |
| 2 | import CryptoKit |
| 3 | import Foundation |
| 4 | |
| 5 | struct PulseMCPSeed: RandomNumberGenerator { |
| 6 | private var state: UInt64 |
| 7 | init(_ seed: String) { |
| 8 | state = SHA256.hash(data: Data(seed.utf8)).prefix(8).reduce(0) { ($0 << 8) | UInt64($1) } |
| 9 | } |
| 10 | mutating func next() -> UInt64 { |
| 11 | state &+= 0x9E3779B97F4A7C15 |
| 12 | var result = state |
| 13 | result = (result ^ (result >> 30)) &* 0xBF58476D1CE4E5B9 |
| 14 | result = (result ^ (result >> 27)) &* 0x94D049BB133111EB |
| 15 | return result ^ (result >> 31) |
| 16 | } |
| 17 | } |
| 18 | #endif |