diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..2eea525
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.env
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 68a49da..416bf9d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,24 +1,7 @@
-This is free and unencumbered software released into the public domain.
+Copyright 2022 Mads Cordes
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
index c9d1007..efe6625 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,53 @@
# moths
-> e**mo**ji au**ths**
+> e**mo**jicon au**th**entication**s**
-# what
+## what
-Emojies as TOTP
+Emojies as OTP (2FA)
-# why
+## why
-Becasue why not?
+Because why not?
-# how
+## how
-Runnig this is quite easy, just run the command:
+Runnig this is quite easy.
-Download the dependencies:
+- Download the dependencies
-```sh
-go mod download
-```
+ ```sh
+ go mod download
+ ```
-Next-up start the program
+- Make a secret
-```sh
-go run .
-```
+ ```sh
+ echo -n "MOTHS_SECRET=" > .env; echo 'moths' | sha256sum | base64 | head -c 32 >> .env
+ ```
+
+- Start the program
+
+ ```sh
+ go run .
+ ```
As I said, easy-peasy!
-# sample
+## sample
+
+![four generated OTP's](./data/sample.png)
+
+
+ v0.1
+
+A sample out-put might be `π»ππΊππ` which would equal the `920811` TOTP-token. Using the super secret secret of `π»` - genereated at `2022/04/28 02:05:42 AM` and a `5`-second interval.
+
+Can be checked out at [`v0.1`](https://github.com/Mobilpadde/moths/tree/v0.1)
-A sample out-put might be `π»ππΊππ` which would equal the `920811` TOTP-token. Using the super secret secret specified in [`./secret.pem`](./secret.pem) - genereated at `2022/04/28 02:05:42` and a `5`-second interval.
+
-# shoutout
+## shoutout
I couldn't have done it without the lovely OSS's listed below:
diff --git a/data/sample.png b/data/sample.png
new file mode 100644
index 0000000..2cace64
Binary files /dev/null and b/data/sample.png differ
diff --git a/generator.go b/generator.go
deleted file mode 100644
index 4b22781..0000000
--- a/generator.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package main
-
-import (
- "encoding/binary"
- "fmt"
- "math"
- "math/bits"
- "math/rand"
- "strings"
-)
-
-// randomBufferFromHOTP generates a random buffer from a HOTP token.
-//
-// /!\ Modified /!\
-//
-// Proudly stolen from https://stackoverflow.com/a/48307199/754471
-func randomBufferFromHOTP(otp string) func(step int) ([]byte, error) {
- buf := []byte(fmt.Sprintf("%08s", otp))
- seed := int64(binary.BigEndian.Uint64(buf))
- r := rand.New(rand.NewSource(seed))
-
- return func(step int) ([]byte, error) {
- buffer := make([]byte, step)
- if _, err := r.Read(buffer); err != nil {
- return nil, err
- }
- return buffer, nil
- }
-}
-
-// MothsGenerator is essentially the nanoid generator with a few modifications.
-//
-// /!\ Modified /!\
-//
-// https://github.com/aidarkhanov/nanoid/blob/master/nanoid.go
-func MothsGenerator(token string, numEmojies int, alphabet ...string) (string, error) {
- emojiBytes := 4
- size := emojiBytes * numEmojies
-
- mask := 2< %s\n", moth, otp)
+ select {}
}
diff --git a/moths/buffer.go b/moths/buffer.go
new file mode 100644
index 0000000..a005dbc
--- /dev/null
+++ b/moths/buffer.go
@@ -0,0 +1,21 @@
+package moths
+
+import (
+ "encoding/binary"
+ "fmt"
+ "math/rand"
+)
+
+func randomBufferFromHOTP(otp string) func(step int) ([]byte, error) {
+ buf := []byte(fmt.Sprintf("%08s", otp))
+ seed := int64(binary.BigEndian.Uint64(buf))
+ r := rand.New(rand.NewSource(seed))
+
+ return func(step int) ([]byte, error) {
+ buffer := make([]byte, step)
+ if _, err := r.Read(buffer); err != nil {
+ return nil, err
+ }
+ return buffer, nil
+ }
+}
diff --git a/moths/config.go b/moths/config.go
new file mode 100644
index 0000000..110221c
--- /dev/null
+++ b/moths/config.go
@@ -0,0 +1,24 @@
+package moths
+
+import "github.com/enescakir/emoji"
+
+var (
+ ALPHABET_CATSDOG = []string{
+ emoji.GrinningCat.String(),
+ emoji.GrinningCatWithSmilingEyes.String(),
+ emoji.CatWithTearsOfJoy.String(),
+ emoji.SmilingCatWithHeartEyes.String(),
+ emoji.CatWithWrySmile.String(),
+ emoji.KissingCat.String(),
+ emoji.WearyCat.String(),
+ emoji.CryingCat.String(),
+ emoji.PoutingCat.String(),
+ emoji.DogFace.String(),
+ }
+)
+
+type Moths struct {
+ secret string
+ interval int
+ alphabet []string
+}
diff --git a/moths/generator.go b/moths/generator.go
new file mode 100644
index 0000000..24cff49
--- /dev/null
+++ b/moths/generator.go
@@ -0,0 +1,49 @@
+package moths
+
+import (
+ "errors"
+ "math"
+ "math/bits"
+ "strings"
+)
+
+const emojiBytes = 4
+
+func (m *Moths) Next(numEmojies int, alphabet []string) (string, error) {
+ if len(alphabet) < 1 {
+ return "", errors.New("alphabet must be at least 1 character")
+ }
+
+ size := emojiBytes * numEmojies
+ // https://github.com/tilaklodha/google-authenticator
+ mask := 2<