Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save massimilianochiodi/4a5e0f655e8158458b6f8eb63bf73372 to your computer and use it in GitHub Desktop.
Save massimilianochiodi/4a5e0f655e8158458b6f8eb63bf73372 to your computer and use it in GitHub Desktop.
Increment Encription Counter Swift ( Little Endian )
public func CtrIncrement() {
let key: Data = Data(bytes: &self.EncryptionCounter, count: MemoryLayout<UInt32>.size) // 1215590466
let keyrev: [UInt8] = key.bytes.reversed()
var value: Int = byte_to_int(dato: Data(keyrev))
value = value + 1
let keyrevdata: Data = Data(bytes: &value, count: MemoryLayout<UInt32>.size)
let keyrevrev: [UInt8] = keyrevdata.bytes.reversed()
let valore: Int = byte_to_int(dato: Data(keyrevrev))
self.EncryptionCounter = valore
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment