Discussion:
Decode-email
(too old to reply)
Mayayana
2018-02-16 01:09:21 UTC
Permalink
I don't know if anyone's interested in this, but
maybe. I don't like to enable script in the browser.
Yet thousands of websites use a specific javascript
to encode email addresses, usually making them
invisible unless one enables script. The decoder
is called decode-email.min.js. It's not just the typical
hex ASCII values. It uses an extra twist, converting
the ASCII values for letters to hex representations
of that number XOR-ed.

I got tired of not being able to find someone's
email, so I wrote a little desktop decoder script.
I also wrote an encoder. The encoder below will
accept ***@somewhere.com53 and return:

35465A58505A5B5075465A5850425D5047501B565A58

That string will be converted back by the decoder.
The 53 is random. It just requires any byte-value
numeric key to do the encoding. The decoder doesn't
need to know it because the encoded string starts
with the key. (H35 = decimal 53)

'----------- begin decoder script ---------------------------

' Script to do the job of email-decode.min.js. This script is used
' on many sites to obfuscate email addresses. The email will be encoded
' as a very long string of characters. Each 2 characters represent a
' hex code, but the first two are a key. That key is then XOR-ed with
' each following pair to get the email characters.
' Example:
' s = "523b3c343d" 'decimal: 82 59 60 52 61

'82 XOR 59 = 105 = i
'82 XOR 60 = 110 = n
'82 XOR 52 = 102 = f
'82 XOR 61 = 111 = o
' s decoded = "info"

s = InputBox("Enter encrypted email address text to decode. This script
works to replace email-decode.min.js, which is used on thousands of
websites.", "Decode email address")
If Len(s) = 0 Then WScript.quit
sRet = InputBox("Decrypted email:", "Decode email address", EmailDecode(s))
WScript.quit

Function EmailDecode(sIn)
Dim iKey, iPos, s2, iVal
iKey = CByte("&H" & Left(sIn, 2)) 'get they XOR key.
iPos = 3
Do While iPos <= Len(sIn)
' get each character pair, treat as hex code and convert to
decimal.
' XOR each with the key value, then treat that as an ASCII
character code and
' convert to character.
s2 = Mid(sIn, iPos, 2)
iVal = cbyte("&H" & s2)
EmailDecode = EmailDecode & Chr(iVal XOR iKey)
iPos = iPos + 2
Loop
End Function

'---------------------- begin encoder script ---------


Dim s, sEmail, sKey, s2, i, iKey, iVal

s = InputBox("Enter email address to encode. Follow that with a 2-digit key
for encoding", "Email address encoder")
If Len(s) = 0 Then WScript.quit

On Error Resume Next
s = Replace(s, " ", "")
sEmail = Left(s, len(s) - 2)
sKey = Right(s, 2)
iKey = cbyte(sKey)
If Err.number <> 0 Then
MsgBox "Error in entering email and encryption key."
WScript.Quit
End If

s2 = Hex(iKey)
For i = 1 to Len(sEmail)
iVal = Asc(Mid(sEmail, i, 1))
iVal = iVal XOR iKey
s2 = s2 & Hex(iVal)
Next

s = InputBox("Encoded email address:", "Encode email address", s2)
WScript.quit
GS
2018-02-16 03:52:24 UTC
Permalink
Decode returns my email address with this appended...

ÕÅ-

..which I assume represents to 2 digit key XOR'd by itself?
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
GS
2018-02-16 04:02:41 UTC
Permalink
Post by GS
Decode returns my email address with this appended...
ÕÅ-
..which I assume represents to 2 digit key XOR'd by itself?
Looking at this closer, it occurs to me that the key needs to be removed from
the encoded string and so I got correct results after revising this line...

Do While iPos <= Len(sIn) - 8

..but I suspect the encode script needs to be revised since a 2 digit key is 4
chars not 8. What say you?
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
GS
2018-02-16 04:34:08 UTC
Permalink
Just FYI:

My email has 19 chars. (21 including key)
The encoded string returned has 39 chars.

If I truncate the encoded string by 7 chars your decode script returns
correctly.
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
GS
2018-02-16 05:44:41 UTC
Permalink
The following 2 digit combos don't work:

00 thru 15
33 thru 47
64 thru 79
96 thru 99
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-16 14:46:33 UTC
Permalink
"GS" <***@v.invalid> wrote

| The following 2 digit combos don't work:
|
| 00 thru 15
| 33 thru 47
| 64 thru 79
| 96 thru 99
|

Interesting. I didn't look into whether there were limits
on the key. The first one I came across was 82. Then
I think I used 53 and 61. I guess it all worked for me
by accident.

So, thanks. You've probably saved me a few
of my remaining hairs. Though I have no plan to ever
use the encoding myself. I just wanted a handy decoder
for when I come across websites using the method. I
came across two this week.
JJ
2018-02-17 15:00:18 UTC
Permalink
Post by Mayayana
Interesting. I didn't look into whether there were limits
on the key. The first one I came across was 82. Then
I think I used 53 and 61. I guess it all worked for me
by accident.
So, thanks. You've probably saved me a few
of my remaining hairs. Though I have no plan to ever
use the encoding myself. I just wanted a handy decoder
for when I come across websites using the method. I
came across two this week.
The error is probably same as mine, where the generated hex string may
contains only 1 digit instead of always 2 digits.
JJ
2018-02-16 18:46:24 UTC
Permalink
Post by Mayayana
I don't know if anyone's interested in this, but
maybe. I don't like to enable script in the browser.
Yet thousands of websites use a specific javascript
to encode email addresses, usually making them
invisible unless one enables script. The decoder
is called decode-email.min.js. It's not just the typical
hex ASCII values. It uses an extra twist, converting
the ASCII values for letters to hex representations
of that number XOR-ed.
You might be interrested on CloudFlare's encrypted email.
You can find out about it by googling "data-cfemail" (with quotes).
Note: the encrypted email isn't visible on the page, since it's stored in
the "data-cfemail" attribute of an achor element (i.e. link).

function DecodeCfEmail(CfEmail)
'decode CloudFlare encrypted email. e.g. from
'"data-cfemail" attribute of an anchor element.
'Data format: {key-byte}{encrypted-email-bytes}
s = ""
if CfEmail <> "" then
key = eval("&H" & left(CfEmail, 2))
for i = 1 to ((len(CfEmail) / 2) - 1)
e = eval("&H" & mid(CfEmail, (i * 2) + 1, 2))
s = s & chr(e xor key)
next
end if
DecodeCfEmail = s
end function

function EncodeCfEmail(email, key)
'encode a CloudFlare-style encrypted email.
'key is a number between &H10 to &HFF.
'if key is 0 or "", and random key will be used.
if email <> "" then
if (key = 0) or (key = "") then
key = 0
while key < &H10
key = cint(rnd * 256)
wend
end if
key = key and &Hff
s = hex(key)
for i = 1 to len(email)
s = s & hex(asc(mid(email, i, 1)) xor key)
next
else
s = ""
end if
EncodeCfEmail = s
end function

'usage example
a = "***@nowhere.net"
wscript.echo "Email: " & a
b = EncodeCfEmail(a, 0)
wscript.echo "Encrypted: " & b
c = DecodeCfEmail(b)
wscript.echo "Decrypted: " & c
GS
2018-02-16 20:30:22 UTC
Permalink
Thanks for your contribution!
As written, it only works when 0 is the key.
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-17 14:29:30 UTC
Permalink
"GS" <***@v.invalid> wrote

| As written, it only works when 0 is the key.
|

It looks like the author of that version made
the same mistake, not handling single-character
hex results in the encoding.
JJ
2018-02-17 14:47:37 UTC
Permalink
Post by GS
Thanks for your contribution!
As written, it only works when 0 is the key.
The EncodeCfEmail function has a bug on converting an integer to a hex
string where the result may only have one hex digit. Sorry about that.
Here's the fix.

function ByteHex(n)
if n > 15 then
ByteHex = hex(n)
else
ByteHex = "0" & hex(n)
end if
end function

function EncodeCfEmail(email, key)
'encode a CloudFlare-style encrypted email.
'key is a number between &H10 to &HFF.
'if key is 0 or "", and random key will be used.
if email <> "" then
if (key = 0) or (key = "") then
key = 0
while key < &H10
key = cint(rnd * 256)
wend
end if
key = key and &Hff
s = ByteHex(key)
for i = 1 to len(email)
s = s & ByteHex(asc(mid(email, i, 1)) xor key)
next
else
s = ""
end if
EncodeCfEmail = s
end function
GS
2018-02-18 00:51:51 UTC
Permalink
This new code throws a typemismatch error when decoding running with your
original usage example!
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 01:33:16 UTC
Permalink
"GS" <***@v.invalid> wrote

| This new code throws a typemismatch error when decoding running with your
| original usage example!
|

Seems to work OK for me. Either way, I think
we have it settled: It works as long as all
encrypted characters end up as 2-byte hex.

I'd never heard of CloudFlare before. They seem
to specialize in content delivery, security and
possibly spyware, claiming to host 7 million sites
as a reverse proxy, man-in-the-middle service.

Oddly, the two sites I've seen are a chiropractor
and a small church. Hardly the kind of sites one
would expect to need CDN. Maybe their webhosts
are running CloudFlare to do the heavy lifting. My
chiropractor seems to be paying $100/month for
a very basic website through iMatrix and using
CloudFlare. I guess she got suckered.
GS
2018-02-18 02:40:09 UTC
Permalink
Post by Mayayana
Post by GS
This new code throws a typemismatch error when decoding running with your
original usage example!
Seems to work OK for me. Either way, I think
we have it settled: It works as long as all
encrypted characters end up as 2-byte hex.
I just created a 2nd .vbs with the new code and added the usage example code
from the original. How did you do it? Can you post your version so I can
compare?
Post by Mayayana
I'd never heard of CloudFlare before. They seem
to specialize in content delivery, security and
possibly spyware, claiming to host 7 million sites
as a reverse proxy, man-in-the-middle service.
Oddly, the two sites I've seen are a chiropractor
and a small church. Hardly the kind of sites one
would expect to need CDN. Maybe their webhosts
are running CloudFlare to do the heavy lifting. My
chiropractor seems to be paying $100/month for
a very basic website through iMatrix and using
CloudFlare. I guess she got suckered.
I use PairNetworks for hosting and nic. Costs me about USD$70/yr!
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
GS
2018-02-18 02:43:08 UTC
Permalink
Duh.., forgot to copy/paste the decode function. sheesh!!
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 03:57:23 UTC
Permalink
"GS" <***@v.invalid> wrote

| I use PairNetworks for hosting and nic. Costs me about USD$70/yr!
|

Isn't that one of the originals from the old days?
I used Earthlink for many years and liked them. But then
I think they changed hands. They started subbing out
the email and I had problems with that. They screwed
up my server logs and didn't seem to care. So I
switched a few years ago. Futurequest.net. $9/month.
A little more than you're paying, but a bargain to my mind.
It's a small, personal-level operation and very responsive.

It's hard to figure the business models. There are hosts
charging hundreds/month for what seems to be just
basic hosting. Other hosts charge more like $3. Yet
both get lots of customers!
GS
2018-02-18 04:10:19 UTC
Permalink
Post by Mayayana
Post by GS
I use PairNetworks for hosting and nic. Costs me about USD$70/yr!
Isn't that one of the originals from the old days?
I used Earthlink for many years and liked them. But then
I think they changed hands. They started subbing out
the email and I had problems with that. They screwed
up my server logs and didn't seem to care. So I
switched a few years ago. Futurequest.net. $9/month.
A little more than you're paying, but a bargain to my mind.
It's a small, personal-level operation and very responsive.
It's hard to figure the business models. There are hosts
charging hundreds/month for what seems to be just
basic hosting. Other hosts charge more like $3. Yet
both get lots of customers!
Yep, my daughter pays a fortune every month for just hosting and NIC is done
elsewhere.

PN includes everything, and they provide 200 mailboxes per domain. I use my own
mail script written in Perl. Other than my contact form, there's no other
scripting anywhere. (I basically only have it to service client file transfers.
If I ever finish my email encryption feature I'll be dropping the website and
use DropBox for file transfers.)
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 04:18:07 UTC
Permalink
"GS" <***@v.invalid> wrote

| Yep, my daughter pays a fortune every month for just hosting and NIC is
done
| elsewhere.
|
What is NIC? I looked it up but haven't found a definition.

| PN includes everything, and they provide 200 mailboxes per domain. I use
my own
| mail script written in Perl. Other than my contact form, there's no other
| scripting anywhere. (I basically only have it to service client file
transfers.
| If I ever finish my email encryption feature I'll be dropping the website
and
| use DropBox for file transfers.)

Email encryption? For the Perl script?
Have we talked about that? I explored
TLS encryption for SMTP awhile back
and got in long discussions with Arne
on m.p.v.b.d, but finally gave up. I
never found any resources that were
properly documented and couldn't get
any option to work.
GS
2018-02-18 04:41:48 UTC
Permalink
Post by Mayayana
Post by GS
Yep, my daughter pays a fortune every month for just hosting and NIC is
done elsewhere.
What is NIC? I looked it up but haven't found a definition.
Post by GS
PN includes everything, and they provide 200 mailboxes per domain. I use my
own mail script written in Perl. Other than my contact form, there's no
other scripting anywhere. (I basically only have it to service client file
transfers. If I ever finish my email encryption feature I'll be dropping the
website and use DropBox for file transfers.)
Email encryption? For the Perl script?
Have we talked about that? I explored
TLS encryption for SMTP awhile back
and got in long discussions with Arne
on m.p.v.b.d, but finally gave up. I
never found any resources that were
properly documented and couldn't get
any option to work.
Well.., I'm implementing a twist to the concept; -I made a project named
"SecureMailAssistant" that allows clients to insert encrypted text into an
email body, or decrypt encrypted text inserted in an email body.

SMA.exe allows a user to compose text and encrypt it, then inserts the
encrypted text for them, but they must copy/paste to decrypt. It's basically
for sending/receiving file open passwords, but it's always been how I've
received/sent license keys for my apps. Now my clients can do similar with
anyone who has SMA.exe. I haven't officially commercialized it yet, but it's
ready for that if it takes off.
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 15:23:15 UTC
Permalink
"GS" <***@v.invalid> wrote

| SMA.exe allows a user to compose text and encrypt it, then inserts the
| encrypted text for them, but they must copy/paste to decrypt. It's
basically
| for sending/receiving file open passwords, but it's always been how I've
| received/sent license keys for my apps. Now my clients can do similar with
| anyone who has SMA.exe. I haven't officially commercialized it yet, but
it's
| ready for that if it takes off.
|
That's a good idea. Encryption without the
drawbacks of TLS. But.... what is NIC?
GS
2018-02-18 15:38:00 UTC
Permalink
Post by Mayayana
Post by GS
SMA.exe allows a user to compose text and encrypt it, then inserts the
encrypted text for them, but they must copy/paste to decrypt. It's
basically for sending/receiving file open passwords, but it's always been
how I've received/sent license keys for my apps. Now my clients can do
similar with anyone who has SMA.exe. I haven't officially commercialized it
yet, but it's ready for that if it takes off.
That's a good idea. Encryption without the
drawbacks of TLS. But.... what is NIC?
PairNic is their domain registry dept.
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 16:09:30 UTC
Permalink
"GS" <***@v.invalid> wrote
| PairNic is their domain registry dept.
|

Oh. I get it. Thanks. I've been paying about
$20/year to Netsol. I guess I'm probably being
cheated, but I just didn't trust a company
that charges almost nothing. As Martin
Mull said, "white people like to buy retail." :)
GS
2018-02-18 18:20:04 UTC
Permalink
Post by Mayayana
Post by GS
PairNic is their domain registry dept.
Oh. I get it. Thanks. I've been paying about
$20/year to Netsol. I guess I'm probably being
cheated, but I just didn't trust a company
that charges almost nothing. As Martin
Mull said, "white people like to buy retail." :)
Well, if you're talking about the likes of 'GoDaddy', I agree. I've heard
horror stories about some SPs that would shock you!

PairNetworks is definitely not one of those! I was paying considerably more
initially (higher level 'package') but got the opportunity to switch over to
their new server at a much better price. Since this server doesn't support
Frontpage Extensions, I had to come up with my own email script for my contact
form page. Otherwise, it's a great SP and I'd recommend them highly to anyone!
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
JJ
2018-02-18 02:47:28 UTC
Permalink
Post by GS
This new code throws a typemismatch error when decoding running with your
original usage example!
Which line?
GS
2018-02-18 02:50:04 UTC
Permalink
Post by JJ
Post by GS
This new code throws a typemismatch error when decoding running with your
original usage example!
Which line?
Sorry friend, my mistake in not copying the decode function to the new file. (I
keep originals until no longer valid)
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-16 23:43:34 UTC
Permalink
"JJ" <***@vfemail.net> wrote

| You might be interrested on CloudFlare's encrypted email.

Cloudflare is the one I wrote it for. Though I'd
guess there may be other sites using it. I had
to figure it out by tracking the values as the
loop ran.
GS
2018-02-17 01:06:36 UTC
Permalink
This post might be inappropriate. Click to display it.
Mayayana
2018-02-17 04:18:02 UTC
Permalink
This post might be inappropriate. Click to display it.
GS
2018-02-17 04:32:28 UTC
Permalink
Post by Mayayana
Post by Mayayana
Post by JJ
You might be interrested on CloudFlare's encrypted email.
Cloudflare is the one I wrote it for. Though I'd
guess there may be other sites using it. I had
to figure it out by tracking the values as the
loop ran.
I'm thinking they use their own proprietary version since a generic version
would be too easy to hack. More likely that Perl(1) or PHP(2) is used!
No, they're using javascript. It's a popular, small script
http://codegists.com/snippet/javascript/email-decodeminjs_zhanglianxin_javascript
Nobody does proprietary. :) Most webmasters don't
knw how to write code. They just use stuff others
have written. If you pull in the various script llibraries
used by big websites you'll usually see things like
an MIT license and author info in them.
The way I worked out the code was to run the
link to the javascript file in the source code, get
that into the browser, and copy it. What surprises
me is how complex it is. There's no concern with
hacking. They'd need something a lot more fancy
for that.
I think I figured out why some numbers don't work.
I'm curious how you found the range that fails. In
any case, I tried 44, in one of the ranges you noted
didn't work. Then I looked at the result and realized
that the problem was a single-character hex code.
A period is 46. 44 xor 46 is 2. That results in all following
characters being misread. But it can be fixed by adding a 0.
s2 = Hex(iKey)
For i = 1 to Len(sEmail)
iVal = Asc(Mid(sEmail, i, 1))
iVal = iVal XOR iKey
'-- make sure a 0 is prepended if Hex result is only one character.
s2 = s2 & Right( "00" & Hex(iVal), 2)
Next
I tested each 2 digit possibility. I'll modify your code with this update and
redo the tests...
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
GS
2018-02-17 05:00:12 UTC
Permalink
The following 2 digit combos still don't work:

00 thru 15
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-17 14:24:02 UTC
Permalink
"GS" <***@v.invalid> wrote in message news:p68csu$hek$***@dont-email.me...
| The following 2 digit combos still don't work:
|
| 00 thru 15
|
Boy, you're thorough. :)

It turns out that's the same problem. If the key is under
16 then the hex version is only one character:
14 = E. 16 = 10

Thus, starting the encoded string with the hex version
of the key must also check to see whether it needs a
zero prepended.
Evertjan.
2018-02-17 15:07:26 UTC
Permalink
Post by Mayayana
|
| 00 thru 15
|
Boy, you're thorough. :)
It turns out that's the same problem. If the key is under
14 = E. 16 = 10
Thus, starting the encoded string with the hex version
of the key must also check to see whether it needs a
zero prepended.
Check?

h = right("0" & h, 2)
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mayayana
2018-02-17 15:46:29 UTC
Permalink
"Evertjan." <***@inter.nl.net> wrote

| h = right("0" & h, 2)
|

Yes. See the other posts. That was already settled.

Though I like to use an extra "0". I know that it
works to do Right("00", 2) but I like to build a string
that's longer than necessary, just to be sure there
are always 2 characters to get. Perhaps more
superstition than logic, but it's harmless.
Evertjan.
2018-02-17 17:18:09 UTC
Permalink
Post by Mayayana
| h = right("0" & h, 2)
|
Yes. See the other posts. That was already settled.
I saw later posts that "settled" for 5 or more lines of code.
Post by Mayayana
Though I like to use an extra "0". I know that it
works to do Right("00", 2) but I like to build a string
that's longer than necessary, just to be sure there
are always 2 characters to get. Perhaps more
superstition than logic, but it's harmless.
I don't think such superstition is harmless,
better build your code by analyzing,
and if the input is a hex number string[!] <= FF and >= 0,
then ...
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
GS
2018-02-18 02:46:42 UTC
Permalink
Post by Mayayana
Post by GS
00 thru 15
Boy, you're thorough. :)
It turns out that's the same problem. If the key is under
14 = E. 16 = 10
Thus, starting the encoded string with the hex version
of the key must also check to see whether it needs a
zero prepended.
So then your version needs to work like JJ's?
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 04:09:18 UTC
Permalink
"GS" <***@v.invalid> wrote

| So then your version needs to work like JJ's?
|

Yes. Didn't you see my later post? The key needs
to be checked to be sure it's 2 characters when it's
written to the encoding. Then each conversion needs
to be 2 characters. There was never any problem
with the basic routine. There was just that glitch.

I wonder what bright bulb at CloudFlare thought
that mess was a good idea. It's a pain in the neck
for no reason. It doesn't need to be so complex to
stop bots. There's no reason to try to lock the email
from visitors. And that method is not secure, anyway.
The only possible purpose I can think of would be
to make the site break if people don't enable script.

But there is one truism that always holds in
tech: People are impressed by obfuscation and
abstruseness. The reason may be no more than
that. someone thought it was clever to encode
an email address in a *wicked* long string. :)
GS
2018-02-18 04:13:16 UTC
Permalink
Post by Mayayana
Post by GS
So then your version needs to work like JJ's?
Yes. Didn't you see my later post? The key needs
to be checked to be sure it's 2 characters when it's
written to the encoding. Then each conversion needs
to be 2 characters. There was never any problem
with the basic routine. There was just that glitch.
Well that's the version I have now that still doesn't work for combos 00-15.
Did I miss a revised posting?
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
GS
2018-02-18 04:23:04 UTC
Permalink
Post by Mayayana
Post by GS
So then your version needs to work like JJ's?
Yes. Didn't you see my later post? The key needs
to be checked to be sure it's 2 characters when it's
written to the encoding. Then each conversion needs
to be 2 characters. There was never any problem
with the basic routine. There was just that glitch.
I wonder what bright bulb at CloudFlare thought
that mess was a good idea. It's a pain in the neck
for no reason. It doesn't need to be so complex to
stop bots. There's no reason to try to lock the email
from visitors. And that method is not secure, anyway.
The only possible purpose I can think of would be
to make the site break if people don't enable script.
But there is one truism that always holds in
tech: People are impressed by obfuscation and
abstruseness. The reason may be no more than
that. someone thought it was clever to encode
an email address in a *wicked* long string. :)
I'm testing...

***@me.com

..with 2 digits appended using this script to encode:

' EncodeEmail.vbs
' by Mayayana 2/15/2018
'---------------------- begin encoder script ---------


Dim s, sEmail, sKey, s2, i, iKey, iVal

s = InputBox("Enter email address to encode. Follow that with a 2-digit key for
encoding", "Email address encoder")
If Len(s) = 0 Then WScript.quit

On Error Resume Next
s = Replace(s, " ", "")
sEmail = Left(s, len(s) - 2)
sKey = Right(s, 2)
iKey = cbyte(sKey)
If Err.number <> 0 Then
MsgBox "Error in entering email and encryption key."
WScript.Quit
End If

s2 = Hex(iKey)
For i = 1 to Len(sEmail)
iVal = Asc(Mid(sEmail, i, 1))
iVal = iVal XOR iKey
'Revised 2/16/2018
'-- make sure a 0 is prepended if Hex result is only one character.
s2 = s2 & Right( "00" & Hex(iVal), 2)
Next

s = InputBox("Encoded email address:", "Encode email address", s2)
WScript.quit
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 15:32:10 UTC
Permalink
"GS" <***@v.invalid> wrote | I'm testing...
|
| ***@me.com
|
| ..with 2 digits appended using this script to encode:
|

I didn't repost the whole thing. Just the correction.
Here it is:

Note that change#2 is what makes sure that all
hex renditions are 2 characters. Then I realized that
the problem with 0-15 was that they key was ending up
as one character. So 10, for example, would be A.
But it needs to be 0A in order to work because the\
script is parsing 2 characters at a time.

So the line marked change#1 is what fixes that.
It's what Evertjan huffily derided as "more
than 5 lines of code". :)
The first version went like so:
s2 = Hex(iKey)
The correction, just before the loop starts, is:
s2 = Right("00" & Hex(iKey), 2)

----------------------------------------
Dim s, sEmail, sKey, s2, i, iKey, iVal

s = InputBox("Enter email address to encode. Follow that with a 2-digit key
for encoding", "Email address encoder")
If Len(s) = 0 Then WScript.quit

On Error Resume Next
s = Replace(s, " ", "")
sEmail = Left(s, len(s) - 2)
sKey = Right(s, 2)
iKey = cbyte(sKey)
If Err.number <> 0 Then
MsgBox "Error in entering email and encryption key."
WScript.Quit
End If

s2 = Right("00" & Hex(iKey), 2) 'change #1
For i = 1 to Len(sEmail)
iVal = Asc(Mid(sEmail, i, 1))
iVal = iVal XOR iKey
s2 = s2 & Right( "00" & Hex(iVal), 2) 'change#2
Next

s = InputBox("Encoded email address:", "Encode email address", s2)
WScript.quit
GS
2018-02-18 15:41:49 UTC
Permalink
Post by Mayayana
I didn't repost the whole thing. Just the correction.
Note that change#2 is what makes sure that all
hex renditions are 2 characters. Then I realized that
the problem with 0-15 was that they key was ending up
as one character. So 10, for example, would be A.
But it needs to be 0A in order to work because the\
script is parsing 2 characters at a time.
So the line marked change#1 is what fixes that.
It's what Evertjan huffily derided as "more
than 5 lines of code". :)
s2 = Hex(iKey)
s2 = Right("00" & Hex(iKey), 2)
----------------------------------------
Dim s, sEmail, sKey, s2, i, iKey, iVal
s = InputBox("Enter email address to encode. Follow that with a 2-digit key
for encoding", "Email address encoder")
If Len(s) = 0 Then WScript.quit
On Error Resume Next
s = Replace(s, " ", "")
sEmail = Left(s, len(s) - 2)
sKey = Right(s, 2)
iKey = cbyte(sKey)
If Err.number <> 0 Then
MsgBox "Error in entering email and encryption key."
WScript.Quit
End If
s2 = Right("00" & Hex(iKey), 2) 'change #1
For i = 1 to Len(sEmail)
iVal = Asc(Mid(sEmail, i, 1))
iVal = iVal XOR iKey
s2 = s2 & Right( "00" & Hex(iVal), 2) 'change#2
Next
s = InputBox("Encoded email address:", "Encode email address", s2)
WScript.quit
Ah! I missed change#1
Thanks, it's been an adventure working this out with you!
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Mayayana
2018-02-18 21:30:48 UTC
Permalink
"GS" <***@v.invalid> wrote

| Ah! I missed change#1
| Thanks, it's been an adventure working this out with you!
|

And it saved me some time. I didn't realize I had bugs
starting out. Funny thing: I find these projects a lot
of fun, but increasingly I have more time than projects.
Whenever I decide to work on something it seems obvious:
Why didn't I think of that before? What a great idea!
But it's not unusual to want to work on something but
have no ideas of what might be useful.
GS
2018-02-18 21:41:45 UTC
Permalink
Post by Mayayana
Post by GS
Ah! I missed change#1
Thanks, it's been an adventure working this out with you!
And it saved me some time. I didn't realize I had bugs
starting out. Funny thing: I find these projects a lot
of fun, but increasingly I have more time than projects.
Why didn't I think of that before? What a great idea!
But it's not unusual to want to work on something but
have no ideas of what might be useful.
Often we'll devise a project for our own use. A surprise is in discovering
others have use for it too!<g>
--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
Continue reading on narkive:
Loading...