1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
---
import Layout from "../layouts/Layout.astro";
const schema = {
"@context": "https://schema.org",
"@type": "ContactPage",
url: "https://www.costas.dev/contact",
headline: "Ponte en contacto conmigo",
};
---
<Layout
title="Contacto"
description="Las formas de ponerte en contacto conmigo, ya sea por correo electrónico, teléfono o redes sociales."
>
<script
is:inline
type="application/ld+json"
slot="head-jsonld"
set:html={JSON.stringify(schema)}
/>
<h1>Contacta conmigo</h1>
<p>
La forma más sencilla de contactar conmigo es a través de mi dirección de
correo electrónico:
<a href="#" id="email-addr">ACTIVA JAVASCRIPT PARA VER ESTO</a>.
</p>
<p>
También puedes encontrarme en GitHub:
<a href="https://github.com/arielcostas">@arielcostas</a>
</p>
</Layout>
<script>
const encryptedEmail = "LygNLiMmFRo/GlQZaFIWBA==";
const key = "NZdKOfvuLn5jF6sryF0Q";
const emailAddrLink = document.getElementById(
"email-addr",
) as HTMLAnchorElement;
(() => {
if (emailAddrLink == null) {
return;
}
const emailAddress = xorData(encryptedEmail, key);
emailAddrLink.href = `mailto:${emailAddress}`;
emailAddrLink.textContent = emailAddress;
})();
function xorData(data: string, key: string): string {
let actualData = atob(data);
let actualKey = key;
const keyLength = key.length;
const dataLength = actualData.length;
const result = new Array(dataLength);
// If the key is 12 characters but the data is 30 characters, the key should be repeated 3 times and truncated to 30 characters
if (keyLength < dataLength) {
actualKey = key
.repeat(Math.ceil(dataLength / keyLength))
.substring(0, dataLength);
} else if (keyLength > dataLength) {
actualKey = key.substring(0, dataLength);
}
for (let i = 0; i < dataLength; i++) {
result[i] = String.fromCharCode(
actualData.charCodeAt(i) ^ actualKey.charCodeAt(i),
);
}
return result.join("");
}
</script>
|