Commit 8e4222d8 authored by Wahyudi's avatar Wahyudi 😎

Add README.md

parents
Pipeline #93 canceled with stages
# Middleware Encryption Client
Small library to help you generate encrypted parameter for middlware requests.
### Todos
- Test on debit credit payment request
- Jenkins pipeline to repo.emhusnan.id
- Compile with JDK Oracle
### How to use on desktop cli
#### Dependencies
- Java Installed openjdk version > `1.8.0_222`
### Usage
Install the dependencies and run following command:
```sh
$ java -jar encrypt.jar --dukpt=[path] --pan=[pan]
```
where parameters:
`--dukpt` = path to your dukpt json file
`--pan` = PAN number
### Example
1. Serialze response key to json and store to `my_dukpt_keys.txt` , file content look like this:
```json
{
"emvKsn": "B9C8F0A0AAA00EE00000",
"pinIpek": "DBC2901375E811B5BE6BD86E57CC8327",
"trackKsn": "B8A516BDB651C5E00000",
"emvIpek": "06536382514030209AA0F8474E24D5AA",
"pinKsn": "631CCEE9FEB0D9E00000",
"trackIpek": "66C2842661221842CEE12AB18F10D923"
}
```
2. Run command
```sh
$ java -jar encrypt.jar --dukpt=my_dukpt_keys.txt --pan=6032984062208826
```
3. Output generated json text, and ready to use for request
```json
{
"trackKsnIndex": "A245F",
"track2Encrypted": "EAE1E7D67129EEE9",
"panHash": "937af3b9d397c958b0a250fe0226f2d72ba5b106e6bf4c92db2c27a9e69accb18353698648cc882f54398b480c15d11bfe4c20cc73a14c7b7f240b263d23f1b7"
}
```
### How to embbed on Android Studio Project
#### Dependencies
1. Copy `encrypt-lib.jar` to folder `app/libs/`
2. add following lines to your `app/build.gradle`
```gradle
implementation 'org.bouncycastle:bcprov-jdk15on:1.54'
implementation 'com.google.code.gson:gson:2.8.5'
implementation files('libs/encrypt-lib.jar')
```
3. Run gradle sync
### Usage
```java
// import dependencies class
import com.mdd.topup.encryption.Encrypt;
import com.mdd.topup.encryption.EncryptedParams;
import com.mdd.topup.encryption.Param;
....
// this is your json response from download key
String keysJson="{\"emvKsn\":\"B9C8F0A0AAA00EE00000\",\"pinIpek\":\"DBC2901375E811B5BE6BD86E57CC8327\",\"trackKsn\":\"B8A516BDB651C5E00000\",\"emvIpek\":\"06536382514030209AA0F8474E24D5AA\",\"pinKsn\":\"631CCEE9FEB0D9E00000\",\"trackIpek\":\"66C2842661221842CEE12AB18F10D923\"}";
// deserialize it to DukptKeys object
DukptKeys keys=new Gson().fromJson(keysJson,DukptKeys.class);
// setup parameter object with PAN and DukptKeys
Param param = new Param();
param.setCardNumber("6032984062208826");
param.setKeys(keys);
// generate encryption
Encrypt encrypt = new Encrypt(param);
EncryptedParams encryptedParams = encrypt.get();
// get the result
String panEnc = encryptedParams.getTrack2Encrypted();
String trackKsnIndex = encryptedParams.getTrackKsnIndex();
String panHash = encryptedParams.getPanHash();
...
```
License
----
PT. Multidaya Dinamika
**term and condition applied**
[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)
[dill]: <https://github.com/joemccann/dillinger>
[git-repo-url]: <https://github.com/joemccann/dillinger.git>
[john gruber]: <http://daringfireball.net>
[df1]: <http://daringfireball.net/projects/markdown/>
[markdown-it]: <https://github.com/markdown-it/markdown-it>
[Ace Editor]: <http://ace.ajax.org>
[node.js]: <http://nodejs.org>
[Twitter Bootstrap]: <http://twitter.github.com/bootstrap/>
[jQuery]: <http://jquery.com>
[@tjholowaychuk]: <http://twitter.com/tjholowaychuk>
[express]: <http://expressjs.com>
[AngularJS]: <http://angularjs.org>
[Gulp]: <http://gulpjs.com>
[PlDb]: <https://github.com/joemccann/dillinger/tree/master/plugins/dropbox/README.md>
[PlGh]: <https://github.com/joemccann/dillinger/tree/master/plugins/github/README.md>
[PlGd]: <https://github.com/joemccann/dillinger/tree/master/plugins/googledrive/README.md>
[PlOd]: <https://github.com/joemccann/dillinger/tree/master/plugins/onedrive/README.md>
[PlMe]: <https://github.com/joemccann/dillinger/tree/master/plugins/medium/README.md>
[PlGa]: <https://github.com/RahulHP/dillinger/blob/master/plugins/googleanalytics/README.md>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment