Contact Stephen Diehl

To try and contact me via email run one of the following scripts to generate my email.

Rust

// Generate contact information for Stephen Diehl
// http://www.stephendiehl.com
use std::arch::x86_64::*;

fn main() {
    let encoded = [
        0x31_u8, 0x36, 0x27, 0x32, 0x2a, 0x27, 0x2c, 0x6c,
        0x2f, 0x6c, 0x26, 0x2b, 0x27, 0x2a, 0x2e, 0x02,
        0x25, 0x2f, 0x23, 0x2b, 0x2e, 0x6c, 0x21, 0x2d,
        0x2f, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00
    ];

    unsafe {
        let key = _mm256_set1_epi8(0x42);
        let data = _mm256_loadu_si256(encoded.as_ptr() as *const __m256i);
        let result = _mm256_xor_si256(data, key);
        let mut output = [0u8; 32];
        _mm256_storeu_si256(output.as_mut_ptr() as *mut __m256i, result);
        print!("Email: {}", String::from_utf8_lossy(&output[..25]));
    }
}

Haskell

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

-- Generate contact information for Stephen Diehl
-- http://www.stephendiehl.com

import Data.Proxy
import GHC.TypeLits
import Data.Char (chr)

-- Simpler type-level XOR using modular arithmetic
type family XorMod (a :: Nat) (b :: Nat) :: Nat where
  XorMod a b = Mod (a + b) 128

type family XorChar (n :: Nat) :: Nat where
  XorChar n = XorMod n 42

-- Type-level list of encoded characters
type EncodedEmail = '[115, 116, 101, 112, 104, 101, 110, 46,
                     109, 46, 100, 105, 101, 104, 108, 64,
                     103, 109, 97, 105, 108, 46, 99, 111, 109]

-- Decode type-level list
type family DecodeList (xs :: [Nat]) :: [Nat] where
  DecodeList '[] = '[]
  DecodeList (x ': xs) = XorChar x ': DecodeList xs

-- Convert Nat to Char at type level
class DecodeEmail (xs :: [Nat]) where
  decodeEmail :: Proxy xs -> String

instance DecodeEmail '[] where
  decodeEmail _ = ""

instance (KnownNat x, DecodeEmail xs) => DecodeEmail (x ': xs) where
  decodeEmail _ = chr (fromIntegral $ natVal (Proxy @x)) : decodeEmail (Proxy @xs)

-- Main entry point
main :: IO ()
main = putStrLn $ decodeEmail (Proxy @(DecodeList EncodedEmail))

RISC-V

// Generate contact information for Stephen Diehl
// http://www.stephendiehl.com
.LC0:
        .string "cdobxod>w>tyoxv0qwkyv>mew"
main:
        addi    sp,sp,-32
        sd      s0,16(sp)
        lui     s0,%hi(.LC0)
        addi    s0,s0,%lo(.LC0)
        sd      s1,8(sp)
        sd      s2,0(sp)
        sd      ra,24(sp)
        addi    s2,s0,25
        lui     s1,%hi(stdout)
.L2:
        lbu     a0,0(s0)
        ld      a1,%lo(stdout)(s1)
        addi    s0,s0,1
        xori    a0,a0,1
        call    putc
        bne     s0,s2,.L2
        ld      ra,24(sp)
        ld      s0,16(sp)
        ld      s1,8(sp)
        ld      s2,0(sp)
        li      a0,0
        addi    sp,sp,32
        jr      ra