hiding

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 3 Imported by: 0

README

Hiding reader library

Overview

The GhostModeGuard package provides functionality for reading computed hiding risk messages. It employs asymmetric cryptography, specifically AES, for secure message handling.

Installation

To use GhostModeGuard, first, install the package by importing it into your project:

import (
	"github.com/ghostmodeguard/hiding"
)

Usage

Request a private key as explained here:

curl -X 'POST' \
'https://api.ghostmodeguard.com/trust/v1/client?domain=[domain of your frontend application]' \
-H 'accept: application/json'

Store it on your application, then create an AESReader instance

aesKey := "your_aes_key_fetched_from_ghost_mode_guard"
reader, err := hiding.NewAESReader(aesKey)
if err != nil {
// Handle error
}

The NewAESReader function takes a series of 32 characters as a string and returns an instance of the Reader interface, which allows you to read computed hiding risk messages.

Read a Computed Hiding Risk Message

encryptedMessage := "encrypted_message_here"
computedHidingRisk, err := reader.Read(encryptedMessage)
if err != nil {
// Handle error
}

// Access computed hiding risk data
// computedHidingRisk contains the decrypted and parsed message

The Read method decrypts the given message using the private key and returns a ComputedHidingRisk structure, containing the parsed message.

Example

package main

import (
	"fmt"
	"github.com/ghostmodeguard/hiding"
)

func main() {
    privateKey := "your_aes_key_fetched_from_ghost_mode_guard"
    reader, err := hiding.NewAESReader(privateKey)
    if err != nil {
        // Handle error
    }

    encryptedMessage := "encrypted_message_here"
    computedHidingRisk, err := reader.Read(encryptedMessage)
    if err != nil {
        // Handle error
    }

    // Access computed hiding risk data
    fmt.Printf("Computed Hiding Risk: %+v\n", computedHidingRisk)
}

Important Notes

  • Ensure that you handle errors appropriately, especially during the creation of the AESReader instance and when reading the computed hiding risk message.
  • The private key should be kept confidential and not shared publicly.

License

GhostModeGuard hiding library reader is licensed under the MIT License. Feel free to use, modify, and distribute it according to the terms of the license.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadPublicKey     = fmt.Errorf("can't parse public key")
	ErrCantReadMessage  = fmt.Errorf("can't read message")
	ErrContentIsNotJson = fmt.Errorf("cmessage content is not json")
)

Functions

This section is empty.

Types

type AESReader added in v0.0.3

type AESReader struct {
	// contains filtered or unexported fields
}

AESReader is the instance that allow to read computed hiding risk message

func (*AESReader) Read added in v0.0.3

func (r *AESReader) Read(msg string) (*ComputedHidingRisk, error)

Read get encrypted message to provide a computed hiding risk

type ComputedHidingRisk

type ComputedHidingRisk struct {
	Verdict                Verdict `json:"v"`
	Token                  string  `json:"t"`
	DenyScore              int     `json:"d"`
	VirtualMachineScore    int     `json:"vm"`
	AntiTrackerScore       int     `json:"a"`
	HideDeviceScore        int     `json:"h"`
	PrivateNavigationScore int     `json:"p"`
	HideRealIPScore        int     `json:"i"`
	BadReputationIPScore   int     `json:"b"`
	RootScore              int     `json:"ro"`
	BotScore               int     `json:"bs"`
}

ComputedHidingRisk is the user hiding risk score

type Reader

type Reader interface {
	Read(msg string) (*ComputedHidingRisk, error)
}

func NewAESReader added in v0.0.3

func NewAESReader(keyStr string) (Reader, error)

NewAESReader creates an instance of Reader

type ReaderSpy

type ReaderSpy struct {
	// contains filtered or unexported fields
}

ReaderSpy is a reader spy

func NewReaderSpy

func NewReaderSpy(risk *ComputedHidingRisk, err error) *ReaderSpy

NewReaderSpy creates a spy instance of Reader

func (*ReaderSpy) GetRecordedMsg

func (r *ReaderSpy) GetRecordedMsg() *string

GetRecordedMsg returns message recorded on Read

func (*ReaderSpy) HasBeenRead

func (r *ReaderSpy) HasBeenRead() bool

HasBeenRead returns if Read method has been called

func (*ReaderSpy) Read

func (r *ReaderSpy) Read(msg string) (*ComputedHidingRisk, error)

Read implements Reader

type Verdict added in v0.0.6

type Verdict string

Verdict of user

const (
	// VerdictOK user is not hiding
	VerdictOK Verdict = "OK"
	// PartiallyHiding user
	PartiallyHiding Verdict = "PARTIALLY_HIDING"
	// Hiding user
	Hiding Verdict = "HIDING"
)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL