aboutsummaryrefslogtreecommitdiff
path: root/Hotline
diff options
context:
space:
mode:
authorJeff Halter <868228+jhalter@users.noreply.github.com>2024-01-22 18:30:11 -0800
committerJeff Halter <868228+jhalter@users.noreply.github.com>2024-01-22 18:30:11 -0800
commit99bdd7a9da8e66ee609ac1d862e25526322b5f9c (patch)
tree296adc03eed349e2ffbaaf93657077b0a4186082 /Hotline
parent184eeb7c873f91b9361f89cec27a999df41f1ab4 (diff)
Fix login/password encoding
Diffstat (limited to 'Hotline')
-rw-r--r--Hotline/Hotline/HotlineProtocol.swift19
1 files changed, 6 insertions, 13 deletions
diff --git a/Hotline/Hotline/HotlineProtocol.swift b/Hotline/Hotline/HotlineProtocol.swift
index 3be58ac..f98e07b 100644
--- a/Hotline/Hotline/HotlineProtocol.swift
+++ b/Hotline/Hotline/HotlineProtocol.swift
@@ -474,21 +474,14 @@ struct HotlineTransactionField {
}
init(type: HotlineTransactionFieldType, string: String, encoding: String.Encoding = .ascii, encrypt: Bool = false) {
- var stringInput = string
-
+ var bytes = [UInt8](string.utf8)
if encrypt {
- stringInput = String(string.utf8.map { char in
- Character(UnicodeScalar(0xFF - char))
- })
- }
-
- var stringData: Data?
- stringData = stringInput.data(using: encoding, allowLossyConversion: true)
- if stringData == nil {
- stringData = Data()
+ bytes = string.utf8.map { char in
+ return 0xFF - char
+ }
}
-
- self.init(type: type, dataSize: UInt16(stringData!.count), data: [UInt8](stringData!))
+
+ self.init(type: type, dataSize: UInt16(bytes.count), data: [UInt8](bytes))
}
init(type: HotlineTransactionFieldType, string: String, encrypt: Bool) {