Contact Stephen Diehl
To try and contact me via email run one of the following scripts to generate my email.
CUDA
// Generate contact information for Stephen Diehl
// http://www.stephendiehl.com
#include <iostream>
#include <vector>
__global__ void decode_stencil(char* decoded, const char* encoded, int n) {
int i = blockIdx.x * blockDim.x + threadIdx.x;
if (i < n) {
decoded[i] = encoded[i] ^ encoded[i+1];
}
}
int main() {
const char encoded[] = {
42, 73, 44, 72, 25, 23, 103, 22, 100, 22, 126, 27, 87, 29,
91, 18, 114, 23, 118, 72, 27, 84, 21, 124
};
const int N = sizeof(encoded) - 1;
char *d_encoded, *d_decoded;
std::vector<char> email(N);
cudaMalloc(&d_encoded, N + 1);
cudaMalloc(&d_decoded, N);
cudaMemcpy(d_encoded, encoded, N + 1, cudaMemcpyHostToDevice);
decode_stencil<<<1, N>>>(d_decoded, d_encoded, N);
cudaMemcpy(email.data(), d_decoded, N, cudaMemcpyDeviceToHost);
cudaFree(d_encoded);
cudaFree(d_decoded);
std::cout << "Email: " << std::string(email.begin(), email.end()) << std::endl;
return 0;
}
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)
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 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]
type family DecodeList (xs :: [Nat]) :: [Nat] where
DecodeList '[] = '[]
DecodeList (x ': xs) = XorChar x ': DecodeList xs
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 :: 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