|
| 1 | + |
| 2 | + |
| 3 | +# HybridCrypto |
| 4 | + |
| 5 | +HybridCrypto is simple implementation of hybrid cryptography recommended by [OWASP](https://mobile-security.gitbook.io/mobile-security-testing-guide/general-mobile-app-testing-guide/0x04g-testing-cryptography). |
| 6 | + |
| 7 | +## Usage |
| 8 | + |
| 9 | +> Step 1: Add this your root build.gradle |
| 10 | +```java |
| 11 | +repositories { |
| 12 | + ... |
| 13 | + maven { url "https://jitpack.io" } |
| 14 | +} |
| 15 | + |
| 16 | +``` |
| 17 | +> Step 2: Add this your app build.gradle |
| 18 | +```java |
| 19 | +dependencies { |
| 20 | + implementation 'com.github.utngypisal:hybrid-crypto:1.0.0' |
| 21 | +} |
| 22 | +``` |
| 23 | + |
| 24 | +> Step 3: Initialize HybridCrypto in your main Application or Activity onCreate() |
| 25 | +```kotlin |
| 26 | +override fun onCreate() { |
| 27 | + val publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvTtZxoq7IKTwRkADtWix\n" + |
| 28 | + "Ryv/CHKK+skNlMMV5G+om75HgHUo8AOzHnj9yUvhcm8Maz46ukxiZsvDPgExu9N1\n" + |
| 29 | + "agEm9HHJEZg1VN+2dT+JojODuC3qkF7o94duchQX44gPjyIBEE/113E6fS51SGGm\n" + |
| 30 | + "WYrCapSYjNRubB97O1WPm/2nK+A/m9KTtCuIZMp4i/qe4mXCLMRepFO2ORBLD5Ac\n" + |
| 31 | + "RU+/tF15IruvaBhZezY+IX571yRao3ZLlVBJtZKU7SHp5udxQ0daRxtsVc9aloC3\n" + |
| 32 | + "TRRL8RvFjHyg7V+uSHkg6cN4IIMrTnkwVkn+7BE9KrT7tY8yEkSE8W4WVCDChIRf\n" + |
| 33 | + "FwIDAQAB\n" |
| 34 | + |
| 35 | + HybridCrypto.initialize(HybridCrypto.Configuration.default, publicKey) |
| 36 | +} |
| 37 | +``` |
| 38 | +> Step 4 (Final): Use it wherever you want |
| 39 | +```kotlin |
| 40 | +HybridCrypto.getInstance() |
| 41 | + .encrypt("Hello") |
| 42 | + .let { Log.d("Test", it.httpParams.toString()) } |
| 43 | +``` |
| 44 | + |
| 45 | +## Result |
| 46 | +Once encryption is successful, you'll get a Http-friendly result object |
| 47 | +```kotlin |
| 48 | +data class HttpFriendlyResult( |
| 49 | + val requestPassword: String, |
| 50 | + val iv: String, |
| 51 | + val salt: String, |
| 52 | + val responsePassword: String, |
| 53 | + val encryptedData: String, |
| 54 | + val signature: String, |
| 55 | +) |
| 56 | +``` |
0 commit comments