-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor package structure & remove v1 API
- Loading branch information
Showing
15 changed files
with
71 additions
and
385 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package paste | ||
|
||
import ( | ||
"github.com/alexedwards/argon2id" | ||
) | ||
|
||
// Paste represents a paste | ||
type Paste struct { | ||
ID string `json:"id"` | ||
Content string `json:"content"` | ||
ModificationToken string `json:"modificationToken,omitempty"` | ||
Created int64 `json:"created"` | ||
Metadata map[string]interface{} `json:"metadata"` | ||
} | ||
|
||
// HashModificationToken hashes the current modification token of a paste | ||
func (paste *Paste) HashModificationToken() error { | ||
hash, err := argon2id.CreateHash(paste.ModificationToken, argon2id.DefaultParams) | ||
if err != nil { | ||
return err | ||
} | ||
paste.ModificationToken = hash | ||
return nil | ||
} | ||
|
||
// CheckModificationToken checks whether or not the given modification token is correct | ||
func (paste *Paste) CheckModificationToken(modificationToken string) bool { | ||
match, err := argon2id.ComparePasswordAndHash(modificationToken, paste.ModificationToken) | ||
return err == nil && match | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.