https://github.com/restuwahyu13/go-jwt-transform
Transform your real jwt token into fake jwt token.
https://github.com/restuwahyu13/go-jwt-transform
Last synced: 5 days ago
JSON representation
Transform your real jwt token into fake jwt token.
- Host: GitHub
- URL: https://github.com/restuwahyu13/go-jwt-transform
- Owner: restuwahyu13
- License: mit
- Created: 2022-11-02T17:40:04.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T07:31:55.000Z (about 1 year ago)
- Last Synced: 2025-03-31T06:25:19.661Z (25 days ago)
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Go JWT Transform

[](https://goreportcard.com/report/github.com/restuwahyu13/go-jwt-transform)
[](https://github.com/restuwahyu13/go-jwt-transform/blob/main/CONTRIBUTING.md)**go-jwt-transform** is a simple utility tool for your transforming a real _jwt token_ into a fake _jwt token_, because if you
store _jwt token_ into a `cookie` or `local storage` very unsafe, your _jwt token_ can be seen data using [jwt.io](https://jwt.io)
website or chrome extension, if you use **go-jwt-transform** you real _jwt token_ cannot seen using [jwt.io](https://jwt.io)
website or chrome extension, because what you save is fake _jwt token_, you can get back real _jwt token_ using decrypt method for
parse fake _jwt token_, if you need decode your fake jwt token in `front end` use [jwt-transform](https://github.com/restuwahyu13/jwt-transform).## Table Of Content
- [Go JWT Transform](#go-jwt-transform)
- [Table Of Content](#table-of-content)
- [Installation](#installation)
- [API Reference](#api-reference)
- [Example Usage](#example-usage)
+ [transfrom](#transfromsecretkey-string-plaintext-string-rotate-uint-byte-error)
+ [untransform](#untransformsecretkey-string-ciphertext-string-rotate-uint-byte-error)
- [Testing](#testing)
- [Bugs](#bugs)
- [Contributing](#contributing)
- [License](#license)## Installation
```bash
go get github.com/restuwahyu13/go-jwt-transform
```## API Reference
- #### Transfrom(secretKey string, plainText: string, rotate: uint): ([]byte, error)
transform jwt token using caesar cipher cryptography from real jwt token into fake jwt token
- #### Untransform(secretKey string, cipherText: string, rotate: uint): ([]byte, error)
untransform jwt token using caesar cipher cryptography from fake jwt token into real jwt token
## Example Usage
Make this as middleware for transform your fake jwt token to real token, because jwt .verify need real token, if you pass
fake token jwt.verify identification your token is not valid and if you not using express, make this as middleware.```go
package mainimport (
"fmt"
"log"jwttransform "github.com/restuwahyu13/go-jwt-transform"
)func main() {
const secretKey string = "46DWzd8YCJyuEsOIy7Mt19sIT4rWaEhP"
const accessToken string = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
const rotate int = 15cipherText, err := jwttransform.Transform(secretKey, accessToken, rotate)
if err != nil {
log.Fatal(err)
}fmt.Println(string(cipherText))
fmt.Print("\n")// fake jwt token
// tnYwqVrxDxYXJoX1CxXhXcG5rRX6XzeMKRY9.tnYosLXxDxXmByB0CIN3DSzlXxlxqbUiOHX6XzekpV4vGV9aXxlxpLU0XydmCIT2ByB5BSXnuF46SLos8NRYnjThDXn7Bi19hXI4gLpTwE.HuaZmlGYHBtZZU2FI4uleBtYu36EDz6nYK_psFhhl5rplainText, err := jwttransform.Untransform(secretKey, string(cipherText), rotate)
if err != nil {
log.Fatal(err)
}fmt.Println(string(plainText))
// real jwt token
// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
}
```## Testing
- Testing Via Local
```sh
go test .
```- Testing Via Docker
```sh
docker build -t go-jwt-transform && docker run go-jwt-transform go test .
```## Bugs
For information on bugs related to package libraries, please visit [here](https://github.com/restuwahyu13/go-jwt-transform/issues)
## Contributing
Want to make **go-jwt-transform** more perfect ? Let's contribute and follow the
[contribution guide.](https://github.com/restuwahyu13/go-jwt-transform/blob/main/CONTRIBUTING.md)## License
- [MIT License](https://github.com/restuwahyu13/go-jwt-transform/blob/master/LICENSE.md)