https://github.com/surfstudio/surf-swiftobfuscator
https://github.com/surfstudio/surf-swiftobfuscator
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/surfstudio/surf-swiftobfuscator
- Owner: surfstudio
- License: mit
- Created: 2022-06-28T05:04:11.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-26T15:21:02.000Z (over 2 years ago)
- Last Synced: 2025-04-13T07:13:25.660Z (about 1 year ago)
- Language: Swift
- Size: 26.4 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SwiftObfuscator
[](https://github.com/surfstudio/Surf-SwiftObfuscator/actions)
[](https://github.com/apple/swift-package-manager)
Byte Code Obfuscator for Strings Encrypting.
[](https://github.com/surfstudio/SurfPlaybook)
## About
Encrypts a string literal, adds a decryption extension to the file with the encrypted string.
## Installation
#### Swift Package Manager
- Into the Xcode `File > Swift Packages > Add Package Dependency`
- Enter repository URL `https://github.com/surfstudio/Surf-SwiftObfuscator`
## Usage
- Right click on the package and select "Show in Finder"
- Right-click on the folder with the "Surf-SwiftObfuscator" package and select "new terminal by folder adress" from the context menu
- In the terminal `swift run SwiftObfuscator [Parameters]`
Parameters:
`-f` or `--file-path ` Path to the file where you want to obfuscate strings.
`-s` or `--salt ` Salt that the strings should be obfuscated with.
`-l` or `--line ` The line number on which strings should be obfuscated. By default, all lines will be obfuscated.
#### Example
To obfuscate all lines in a file in the terminal that opens, type:
```bash
swift run SwiftObfuscator -f ../MyProject/Tokens.swift -s somesalt
```
If you need to obfuscate a specific string then use:
```bash
swift run SwiftObfuscator -f ../MyProject/Tokens.swift -s somesalt -l 135
```
#### Result example
File before change:
```swift
import UIKit
class ViewController: UIViewController {
enum Tokens {
static let value1 = "value1"
static let value2 = "value2"
static let value3 = "value3"
}
override func viewDidLoad() {
super.viewDidLoad()
print("string1", "string2")
}
}
```
File after change:
```swift
// swiftlint:disable line_length
import Obfuscator
import UIKit
class ViewController: UIViewController {
enum Tokens {
// Obfuscated from "value1"
static let value1 = Obfuscator.default.reveal(key: [7, 22, 9, 7, 20, 70]) ?? ""
// Obfuscated from "value2"
static let value2 = Obfuscator.default.reveal(key: [7, 22, 9, 7, 20, 69]) ?? ""
// Obfuscated from "value3"
static let value3 = Obfuscator.default.reveal(key: [7, 22, 9, 7, 20, 68]) ?? ""
}
override func viewDidLoad() {
super.viewDidLoad()
print(Obfuscator.default.reveal(key: [2, 3, 23, 27, 31, 16, 84]) ?? "", Obfuscator.default.reveal(key: [2, 3, 23, 27, 31, 16, 87]) ?? "")
}
}
fileprivate extension Obfuscator {
@inline(__always)
static var `default`: Obfuscator {
return Obfuscator(withSalt: "qwer")
}
}
```
## Changelog
You can see list of all changes in this [file](./CHANGELOG.md).
## License
[MIT License](./LICENSE)