Skip to content

Commit

Permalink
iOS: remove trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdapioneer committed Nov 23, 2023
1 parent a386fef commit 673e549
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions ios/RainbowSloth/Sources/RainbowSloth/PwHash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation

/// Wrapper around the Argon2id password hashing algorithm as provided by `Sodium`.
internal struct PwHash {

/// Derives a key from the given `salt` and password `pw`. The output will be `outputLength` bytes long.
internal static func derive(salt: Data, pw: Data, outputLength: Int) -> Data {
// OWASP: "Use Argon2id with a minimum configuration of 19 MiB of memory, an iteration count of 2, and 1 degree of parallelism."
Expand All @@ -18,7 +18,7 @@ internal struct PwHash {
)
return Data(res!)
}

/// Creates a new random `salt` byte array that can be used with the `derive` function.
internal static func randomSalt(outputLength: Int = 16) -> Data {
var bytes = [UInt8](repeating: 0, count: outputLength)
Expand Down
2 changes: 1 addition & 1 deletion ios/RainbowSloth/Sources/RainbowSloth/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation


internal extension Data {

/// Creates a new `Data` object initialized with bytes decoded from the provided hexadecimal-encoded String.
init(hex: String) {
let l = hex.count / 2
Expand Down
8 changes: 4 additions & 4 deletions ios/RainbowSloth/Tests/RainbowSlothTests/PwHashTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import XCTest

final class PwHashTests: XCTestCase {

func testPwHashOutputLengthMatches() throws {
let pw = "test".data(using: .utf8)!
let salt = Data(hex: "0123456789ABCDEF0123456789ABCDEF")
Expand All @@ -11,7 +11,7 @@ final class PwHashTests: XCTestCase {

XCTAssertEqual(res.count, 42)
}

func testPwHashDifferentPasswordsDifferentOutput() throws {
let pw1 = "test".data(using: .utf8)!
let pw2 = "test2".data(using: .utf8)!
Expand All @@ -22,7 +22,7 @@ final class PwHashTests: XCTestCase {

XCTAssertNotEqual(res1, res2)
}

func testPwHashDifferentSaltsDifferentOutput() throws {
let pw = "test".data(using: .utf8)!
let salt1 = Data(hex: "0123456789ABCDEF0123456789ABCDEF")
Expand All @@ -33,7 +33,7 @@ final class PwHashTests: XCTestCase {

XCTAssertNotEqual(res1, res2)
}

func testPwHashSameParametersSameOutput() throws {
let pw = "test".data(using: .utf8)!
let salt = Data(hex: "0123456789ABCDEF0123456789ABCDEF")
Expand Down
10 changes: 5 additions & 5 deletions ios/Sloth/Sloth/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,29 @@ struct ContentView: View {
Spacer()
Text("Rainbow Sloth 🦥").font(.title)
Spacer()

Text("Experiment to run:").font(.headline)
Picker("Experiment", selection: $taskSelection, content: {
Text("SE-OP").tag("seop")
Text("RainbowSloth").tag("sloth")
}).disabled(isRunning)

Text("Rainbow parameter n:").font(.headline)
Picker("Rainbow parameter n", selection: $n, content: {
Text("1").tag(1)
Text("10").tag(10)
Text("100").tag(100)
Text("1000").tag(1000)
}).disabled(isRunning || taskSelection != "sloth")

Text("Number of experiment iterations:").font(.headline)
Picker("Number of experiment iterations", selection: $iterations, content: {
Text("1").tag(1)
Text("10").tag(10)
Text("100").tag(100)
Text("1000").tag(1000)
}).disabled(isRunning)

Button("Start run") {
taskOutput = "started"
isRunning = true
Expand All @@ -116,7 +116,7 @@ struct ContentView: View {
}
.buttonStyle(.borderedProminent)
.padding().disabled(isRunning)

Text("Status/output:").font(.headline)
if isRunning {
ProgressView()
Expand Down
2 changes: 2 additions & 0 deletions ios/scripts/remove_trailing_whitespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
find . -iname '*.swift' -type f -exec sed -i '' 's/[[:space:]]\{1,\}$//' {} \+;

0 comments on commit 673e549

Please sign in to comment.