https://github.com/benjaminch/pricers
This library supports RTB development for Open RTB common price encryption in Golang.
https://github.com/benjaminch/pricers
go golang golang-library openrtb price-encryption
Last synced: about 1 year ago
JSON representation
This library supports RTB development for Open RTB common price encryption in Golang.
- Host: GitHub
- URL: https://github.com/benjaminch/pricers
- Owner: benjaminch
- License: gpl-3.0
- Created: 2017-11-25T14:08:24.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-10T17:31:19.000Z (about 3 years ago)
- Last Synced: 2025-04-20T04:34:18.486Z (about 1 year ago)
- Topics: go, golang, golang-library, openrtb, price-encryption
- Language: Go
- Homepage:
- Size: 77.1 KB
- Stars: 9
- Watchers: 1
- Forks: 5
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pricers
[](https://travis-ci.org/benjaminch/pricers)
[](https://godoc.org/github.com/benjaminch/pricers)
[](https://goreportcard.com/report/github.com/benjaminch/pricers)
[](https://codeclimate.com/github/benjaminch/pricers/maintainability)
[](https://codeclimate.com/github/benjaminch/pricers/test_coverage)


## Overview
This library supports RTB development for Open RTB common price encryption in Golang.
## Installation
```bash
$ go get github.com/benjaminch/pricers
```
## Supported encryption protocols
### Google Private Data
Specs https://developers.google.com/ad-exchange/rtb/response-guide/decrypt-price
#### Examples
##### Creating a new Google Private Data Pricer
```golang
import "github.com/benjaminch/pricers/doubleclick"
var pricer *doubleclick.DoubleClickPricer
var err error
pricer, err = doubleclick.NewDoubleClickPricer(
"ZS-DraBUUVeht_sMDgn1nnM3My_nq9TrEESbjubDkTU", // Encryption key
"vQo9-4KtlcXmPhWaYvc8asqYuiSVMiGUdZ1RLXfrK7U", // Integrity key
true, // Keys are base64
helpers.Utf8, // Keys should be ingested as Utf-8
1000000, // Price scale Factor Micro
false, // No debug
)
```
##### Encrypting a clear price
```go
import "github.com/benjaminch/pricers/doubleclick"
var result string
var err error
price := 42 // Clear price
seed := ""
result, err = pricer.Encrypt(seed, price)
if err != nil {
err = errors.New("Encryption failed. Error : %s", err)
}
```
##### Decrypting an encrypted price
```go
import "github.com/benjaminch/pricers/doubleclick"
var result float64
var err error
encryptedPrice := "WEp8nQAAAAADG-y45xxIC1tMWuTjzmDW6HtroQ"
result, err = pricer.Decrypt(encryptedPrice)
if err != nil {
err = errors.New("Decryption failed. Error : %s", err)
}
```
## Todos
- [ ] Re-organize directory layout following https://github.com/golang-standards/project-layout
- [ ] Complete documentation:
- [ ] How to use the Pricer Builder (describing all params)
- [ ] How to use the Pricer Encrypt function (describing all params)
- [ ] How to use the Pricer Decrypt function (describing all params)
- [ ] Complete tests for helpers
- [ ] Complete tests for Google Private Data, including various key formats (hex, utf8, base64, etc.)
- [ ] Add other most common price encryption protocols (AES, etc.)
- [ ] BlowFish
- [ ] Symetric Algorithm
- [ ] XOR