mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
⚡ Chore: unified content encryption function
This commit is contained in:
@@ -16,16 +16,8 @@
|
||||
|
||||
{{- /* Content */ -}}
|
||||
{{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
{{- if $params.password -}}
|
||||
{{- $saltLen := strings.RuneCount (trim $params.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 $params.password) $saltLen)
|
||||
(substr $base64EncodeContent $saltLen)
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- /* Content Encryption */ -}}
|
||||
{{- $content = dict "Content" $content "Password" $params.password | partial "function/content-encryption.html" | safeHTML -}}
|
||||
<div class="content" id="content"
|
||||
{{- with $params.password }} data-password="{{ hash.XxHash . }}"{{ end }}
|
||||
{{- with $params.password }} data-content="{{ $content }}"{{ end -}}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{{- $content := .Content -}}
|
||||
|
||||
{{- if .Password -}}
|
||||
{{- $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)
|
||||
-}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $content -}}
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- .Scratch.Set "version" "v0.3.10-466bb7b7" -}}
|
||||
{{- .Scratch.Set "version" "v0.3.10-91f3c7c3" -}}
|
||||
{{- .Scratch.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -160,16 +160,8 @@
|
||||
|
||||
{{- /* Content */ -}}
|
||||
{{- $content := dict "Content" .Content "Ruby" $params.ruby "Fraction" $params.fraction "Fontawesome" $params.fontawesome | partial "function/content.html" | safeHTML -}}
|
||||
{{- if $params.password -}}
|
||||
{{- $saltLen := strings.RuneCount (trim $params.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 $params.password) $saltLen)
|
||||
(substr $base64EncodeContent $saltLen)
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- /* Content Encryption */ -}}
|
||||
{{- $content = dict "Content" $content "Password" $params.password | partial "function/content-encryption.html" | safeHTML -}}
|
||||
<div class="content" id="content"
|
||||
{{- with $params.endFlag }} data-end-flag="{{ . }}"{{ end }}
|
||||
{{- with $params.password }} data-password="{{ xxhash . }}"{{ end }}
|
||||
|
||||
@@ -10,15 +10,10 @@
|
||||
{{- end -}}
|
||||
|
||||
{{- if $password -}}
|
||||
{{- /* Content */ -}}
|
||||
{{- $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)
|
||||
-}}
|
||||
{{- /* Content Encryption */ -}}
|
||||
{{- $content = dict "Content" $content "Password" $password | partial "function/content-encryption.html" | safeHTML -}}
|
||||
|
||||
<fixit-encryptor class="fixit-encryptor-shortcode">
|
||||
<div class="fixit-decryptor-container">
|
||||
|
||||
Reference in New Issue
Block a user