mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-27 09:05:19 +00:00
* Extract BitchatMessage into a separate file * Convert `fromBinaryPayload` to `convenience init?` * Extract message dedup into an extension * Remove dead `formatMessageContent` * Minor refactor of timestamp and username formatting * Remove dead `getSenderColor` * Extract MessagePadding into a separate file * Extract BitchatPacket into a separate file * Extract ReadReceipt into a separate file * Extract NoisePayload into a separate file * Remove unnecessary import * Extract peer-seed color calculation out * Extract `handleDeliveredReadReceipt` to a new function * Extract `handlePrivateMessage` to a new function * Separate `delivered` and `readReceipt` functions * Extract `handleGiftWrap` into a function * Extract `subscribeToGeoChat` into a function * Minor cleanup * Extract `handleNostrEvent` into a function * Minor cleanup * Create `sendGeohash` function + minor cleanup * Extract sending geohash dm into a function * Check for blocks before trying to send a DM
18 lines
364 B
Swift
18 lines
364 B
Swift
//
|
|
// String+DJB2.swift
|
|
// bitchat
|
|
//
|
|
// This is free and unencumbered software released into the public domain.
|
|
// For more information, see <https://unlicense.org>
|
|
//
|
|
|
|
import Foundation
|
|
|
|
extension String {
|
|
func djb2() -> UInt64 {
|
|
var hash: UInt64 = 5381
|
|
for b in utf8 { hash = ((hash << 5) &+ hash) &+ UInt64(b) }
|
|
return hash
|
|
}
|
|
}
|