mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 23:38:56 +00:00
🎉 Feat: add shortcode fixit-encryptor template (#123)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
{{- $password := .Get 0 | default "" -}}
|
||||
|
||||
{{- if $password -}}
|
||||
{{- $content := .Inner | .Page.RenderString -}}
|
||||
{{- $saltLen := strings.RuneCount (trim $password "") -}}
|
||||
{{- $saltLen = cond (eq (mod $saltLen 2) 0) (add $saltLen 1) $saltLen -}}
|
||||
{{- $base64EncodeContent := $content | base64Encode -}}
|
||||
{{- $content = printf "%v%v%v"
|
||||
(substr $base64EncodeContent 0 $saltLen)
|
||||
(substr (sha256 $password) $saltLen)
|
||||
(substr $base64EncodeContent $saltLen)
|
||||
-}}
|
||||
<fixit-encryptor data-password="{{ $password }}" data-content="{{ $content }}"></fixit-encryptor>
|
||||
{{- partial "single/fixit-decryptor.html" . -}}
|
||||
{{- else -}}
|
||||
{{- .Inner -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user