Skip to content

Commit ee07656

Browse files
author
Utngy Pisal
committed
Added readme
1 parent 7709e23 commit ee07656

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,49 @@
11
# HybridCrypto
22

3-
A description of this package.
3+
HybridCrypto is simple implementation of hybrid cryptography following recommendations by [OWASP](https://mobile-security.gitbook.io/mobile-security-testing-guide/general-mobile-app-testing-guide/0x04g-testing-cryptography).
4+
5+
## Usage
6+
7+
> Step 1: Add this package to our Swift project via Swift Package Manager (SPM)
8+
```java
9+
https://github.com/UTNGYPisal/SwiftHybridCrypto
10+
11+
```
12+
> Step 2: Import package to classes you need to work with encryption
13+
```swift
14+
import HybridCrypto
15+
```
16+
17+
> Step 3: Initialize HybridCrypto in your AppDelegate
18+
```swift
19+
let publicKeyPlain = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvTtZxoq7IKTwRkADtWix\n" +
20+
"Ryv/CHKK+skNlMMV5G+om75HgHUo8AOzHnj9yUvhcm8Maz46ukxiZsvDPgExu9N1\n" +
21+
"agEm9HHJEZg1VN+2dT+JojODuC3qkF7o94duchQX44gPjyIBEE/113E6fS51SGGm\n" +
22+
"WYrCapSYjNRubB97O1WPm/2nK+A/m9KTtCuIZMp4i/qe4mXCLMRepFO2ORBLD5Ac\n" +
23+
"RU+/tF15IruvaBhZezY+IX571yRao3ZLlVBJtZKU7SHp5udxQ0daRxtsVc9aloC3\n" +
24+
"TRRL8RvFjHyg7V+uSHkg6cN4IIMrTnkwVkn+7BE9KrT7tY8yEkSE8W4WVCDChIRf\n" +
25+
"FwIDAQAB"
26+
HybridCrypto.initialize(with: Configuration.defaultCofig, publicKeyPlain: publicKeyPlain)
27+
```
28+
> Step 4 (Final): Use it wherever you want
29+
```swift
30+
do {
31+
let result = try HybridCrypto.shared.encrypt(message: "Hello")
32+
print(result.httpParams)
33+
} catch let err {
34+
print("Error: \(err)")
35+
}
36+
```
37+
38+
## Result
39+
Once encryption is successful, you'll get a Http-friendly result object
40+
```swift
41+
public struct HttpFriendlyResult : Codable {
42+
let requestPassword: String
43+
let iv: String
44+
let salt: String
45+
let responsePassword: String
46+
let encryptedData: String
47+
let signature: String
48+
}
49+
```

0 commit comments

Comments
 (0)