From c2e515b457a4141b2bf7951d11cfe61d6d3223c8 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Sun, 12 Jun 2022 12:12:26 +0800 Subject: [PATCH] :tada: Feat: add shortcode fixit-encryptor template (#123) --- layouts/shortcodes/fixit-encryptor.html | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 layouts/shortcodes/fixit-encryptor.html diff --git a/layouts/shortcodes/fixit-encryptor.html b/layouts/shortcodes/fixit-encryptor.html new file mode 100644 index 00000000..2e8a21e3 --- /dev/null +++ b/layouts/shortcodes/fixit-encryptor.html @@ -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) + -}} + + {{- partial "single/fixit-decryptor.html" . -}} +{{- else -}} + {{- .Inner -}} +{{- end -}} \ No newline at end of file