Skip to content

Commit

Permalink
page init (#2)
Browse files Browse the repository at this point in the history
* use style.css for loader css styling

* add demo url

* centered decrypt input

* deploy example on main branch
  • Loading branch information
richardjennings authored Apr 28, 2024
1 parent 454df5e commit a0748b7
Show file tree
Hide file tree
Showing 8 changed files with 472 additions and 6 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and Deploy Example
on:
push:
branches:
- main
permissions:
contents: write
pages: write
id-token: write
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
uses: actions/checkout@v4

- name: Install and Build 🔧
run: |
make build
mkdir -p build
./precrypt "passphrasewhichneedstobe32bytes!" > build/index.html

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
PreCrypt generates a HTML page which can self load embedded AES GCM encrypted HTML, CSS, Javascript when a correct
passcode is entered.

The demo example is available on [Github Pages](https://richardjennings.github.io/precrypt/).

## Status

Work in progress currently only supporting embedding content from the `example` directory.
Expand All @@ -13,3 +15,5 @@ Work in progress currently only supporting embedding content from the `example`
go run main.go passphrasewhichneedstobe32bytes! > index.html
open index.html
```


7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var indexTemplate string
//go:embed dist/main.js
var loaderJs string

//go:embed dist/style.css
var loaderCss string

//go:embed example/index.html
var exampleHtml []byte

Expand All @@ -26,7 +29,7 @@ var exampleJs []byte

func main() {
key := os.Args[1]
htmlEnc, err := precrypt.Encrypt(exampleHtml, []byte(key));
htmlEnc, err := precrypt.Encrypt(exampleHtml, []byte(key))
e(err)
cssEnc, err := precrypt.Encrypt(exampleCss, []byte(key))
e(err)
Expand All @@ -39,7 +42,7 @@ func main() {
"c": []string{string(jsEnc)},
})
e(err)
err = tmpl.Execute(os.Stdout, map[string]interface{}{"data": string(data), "js": string(loaderJs)})
err = tmpl.Execute(os.Stdout, map[string]interface{}{"data": string(data), "js": loaderJs, "css": loaderCss})
e(err)
}

Expand Down
Loading

0 comments on commit a0748b7

Please sign in to comment.