Author Posts

October 29, 2015 at 4:14 am

Hi,

This clever chap has used the below to display his e-mail address.

I can work some of it out, string length is 33, foreach Character or number...

then i'm not sure how hes done the rest ? Quite like to do it for my e-mail !

[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

October 29, 2015 at 5:19 am

This will generate the number string for you:

You then have to replace the (0..33) range expression to reflect the length of your email minus one as it is a null-based array.

Cheers

October 29, 2015 at 5:28 am

Sorry Tore, what will generate the number string ?

October 29, 2015 at 5:40 am

Thank you.
Could you break it down so i can understand it a bit more please ?

October 29, 2015 at 6:36 am

Here is how it works. It should be easier to read if you copy and paste into the Windows Powershell ISE

[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

# Let's space it out

[string](0..33 |
         % {
               [char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))
           }
        )-replace " "

# Let's replace the shorthand

[string](0..33 |
         ForEach-Object {
                            [char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))
                        }
        )-replace " "

# Now Let's read it

# [string]() cast the result of processing everything in the () as a string. So inside of the () we have.

0..33 |
         ForEach-Object {
                            [char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))
                        }

# We start with a range 0 to 33.
0, 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 |
         ForEach-Object {
                            [char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))
                        }

# That is then piped into a ForEach-Object. The basic result is that the formula in the foreach-object block will run for the for the number
# of times specified by the range. In this case 34 times. If we start plugging in the value from the range we can calculate the formula
[char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))

# Substituing the first object in the range, 0, for $_, we get the below.
[char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring((0*2),2))

# 0 * 2 is 0, so the result is that we are going to take a substring of the below number starting at position 0 and only continue for 2 characters
[char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(0,2))

# The result of the substring above is 68. We then add 46 to 68
[char][int](46 + 68)

# The result of that addition is 114
[char][int](114)

# The result is then cast as an integer and then as a charater. The result of the casting is the character who's ASCII number is 114
r

# This then repeats for each number in the range
[char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring((1*2),2))
[char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring(2,2))
[char][int](46 + 65)
[char][int](111)
o

[char][int](46 + ("686552495351636652556262185355647068516270555358646562655775 0645570").substring((2*2),2))
b

# etc.etc.

# After the ForEach-Object loop has finished processing for each value in the range you end up with an array of string objects inside of the ()
[string]("r", "o", "b", "_", "c", "a", "m", "p", "b", "e", "l", "l", "@", "c", "e", "n", "t", "r", "a", "l", "t", "e", "c", "h", "n", "o", "l", "o", "g", "y", ".", "n", "e", "t")-replace " "

# [string] casts the value inside of the () as a string instead of an array, which bacially joins all of the array elements together into a string
# with a space between each element of the array
"r o b _ c a m p b e l l @ c e n t r a l t e c h n o l o g y . n e t"-replace " "

# And finally -replace " " replaces all the space characters with nothing
"rob_campbell@centraltechnology.net"

October 29, 2015 at 7:20 am

Thank you very much Curtis for taking the time to do this. I will paste it in the ISE and go through it.

October 29, 2015 at 12:38 pm

Curtis – respect!