Skip to content

Commit

Permalink
feat: use Wasm to compute email addr
Browse files Browse the repository at this point in the history
  • Loading branch information
rnmeow committed Oct 6, 2024
1 parent 1870675 commit b22e8b1
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,35 @@
import VueWriter from 'vue-writer'
import { SOCIAL_LINKS } from '@/config/links'
const arr = [
0x64, 0x47, 0x39, 0x31, 0x59, 0x32, 0x68, 0x41, 0x63, 0x6d, 0x35, 0x74, 0x5a, 0x57, 0x39, 0x33,
0x4c, 0x6d, 0x4e, 0x76, 0x62, 0x51, 0x3d, 0x3d
]
if (process.client) {
localStorage.setItem('email', atob(String.fromCharCode.apply(null, arr)))
const { instance } = await WebAssembly.instantiate(
new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 127, 3, 2, 1, 0, 5, 3, 1, 0, 1, 7, 23, 2, 10,
103, 101, 116, 95, 108, 101, 110, 103, 116, 104, 0, 0, 6, 109, 101, 109, 111, 114, 121, 2, 0,
10, 6, 1, 4, 0, 65, 16, 11, 11, 22, 1, 0, 65, 0, 11, 16, 146, 147, 134, 80, 152, 143, 126,
133, 133, 136, 85, 124, 118, 135, 128, 132
])
)
const mem = instance.exports.memory as WebAssembly.Memory
const len = instance.exports.get_length as CallableFunction
const arr = new Uint8Array(mem.buffer, 0, len() satisfies number)
for (let i = 0; i < Math.floor(arr.length / 2); i++) {
let tmp = arr[i]
arr[i] = arr[arr.length - 1 - i]
arr[arr.length - 1 - i] = tmp
}
let cnt = 0x0f
for (let i = 0; i < arr.length; i++) {
arr[i] -= i < 0x0a ? ++cnt : cnt++ - (-244 + 0xed)
}
localStorage.setItem('email', new TextDecoder().decode(arr))
}
const emailAddr = ref('')
Expand Down

0 comments on commit b22e8b1

Please sign in to comment.