https://github.com/metrico/pasticca
Store and Retrieve JSON data from pastila for fun a profit-loss
https://github.com/metrico/pasticca
Last synced: about 1 month ago
JSON representation
Store and Retrieve JSON data from pastila for fun a profit-loss
- Host: GitHub
- URL: https://github.com/metrico/pasticca
- Owner: metrico
- Created: 2024-09-25T18:43:10.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-29T19:57:53.000Z (about 1 year ago)
- Last Synced: 2025-04-02T06:02:18.743Z (7 months ago)
- Language: Go
- Homepage:
- Size: 38.1 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 💊 pasticca
Store and Retrieve data from `pastila` in Go for fun & profit-loss## Usage
```go
import ("github.com/metrico/pasticca/paste")
```## Example
See `main.go`#### Plaintext/JSON
```go
// Example: Save some content
content := "This is a test paste."
fingerprint, hashWithAnchor, err := paste.Save(content, "", "", false)
if err != nil {
log.Fatalf("Error saving paste: %v", err)
}
hash := strings.Split(hashWithAnchor, "#")[0] // Remove anchor if present
fmt.Printf("Saved paste with fingerprint/hash: %s/%s\n", fingerprint, hash)// Example: Load the content we just saved
loadedContent, isEncrypted, err := paste.Load(fingerprint, hash)
if err != nil {
log.Fatalf("Error loading paste: %v", err)
}
fmt.Printf("Loaded content: %s\nIs encrypted: %v\n", loadedContent, isEncrypted)
```
```
Saved paste with fingerprint/hash: xxxxxxx/yyyyyyyyyyy
Loaded content: This is a test paste.
Is encrypted: false
```#### Encrypted
```go
// Example: Save encrypted content
encryptedContent := "This is a secret message."
fingerprint, hashWithAnchor, err := paste.Save(encryptedContent, "", "", true)
if err != nil {
log.Fatalf("Error saving encrypted paste: %v", err)
}
fmt.Printf("Saved paste with fingerprint/hash: %s/%s\n", fingerprint, hashWithAnchor)// Example: Load and decrypt the encrypted content
decryptedContent, isEncrypted, err := paste.Load(fingerprint, hashWithAnchor)
if err != nil {
log.Fatalf("Error loading encrypted paste: %v", err)
}
fmt.Printf("Decrypted content: %s\nIs encrypted: %v\n", decryptedContent, isEncrypted)
```
```
Saved encrypted paste with fingerprint/hash: xxxxxxx/yyyyyyyyyyy#zzzzzzzzzz==
Loaded and decrypted content: This is a secret message.
Is encrypted: true
```