From: Bee on
I am fiddling with this piece of code i got from someplace. I can't remember
where. Some time ago. Thanks to whomever for the snippet.

It works for pure ASCII text that I have tried.
I am trying to get it to work on .RTF text but I do not understand enough to
get it going.
Someone please show me how to do this.
If this is not possible, then what is another fast method.
This is only for a paragraph or so of text.

The text may be coming from a "string", a TextBox or a RichTextBox.
If it is from a RichTextBox i want to preserve all the formatting.

Public Function CryptoEasy(sPlaintext As String) As String
'
' Same routine to encrypt and decrypt
On Error GoTo CryptoEasyErr

Dim n As Long
Dim C As Long

CryptoEasy = StrReverse(sPlaintext)
For n = 1 To Len(CryptoEasy)
C = Asc(Mid$(CryptoEasy, n, 1))

Mid$(CryptoEasy, n, 1) = Chr$(C)

If C > 32 Then
If C > 127 Then
C = 383 - C
Else
C = 160 - C
End If
Mid$(CryptoEasy, n, 1) = Chr$(C)
End If
Next

CryptoEasyExit:
Exit Function

CryptoEasyErr:
Debug.Assert False
'Resume
Resume CryptoEasyExit

End Function 'CryptoEasy

From: Mike B on
About 5 or 6 years ago I used this module written by Barry Dunne. I haven't
used it since, but at the time it was pretty easy to implement, so it begs
to be not reinvented.

http://www.codeguru.com/forum/archive/index.php/t-14588.html


"Bee" <Bee(a)discussions.microsoft.com> wrote in message
news:427E1D2E-2405-4406-984F-6B0EBF0E4B22(a)microsoft.com...
>I am fiddling with this piece of code i got from someplace. I can't
>remember
> where. Some time ago. Thanks to whomever for the snippet.
>
> It works for pure ASCII text that I have tried.
> I am trying to get it to work on .RTF text but I do not understand enough
> to
> get it going.
> Someone please show me how to do this.
> If this is not possible, then what is another fast method.
> This is only for a paragraph or so of text.
>
> The text may be coming from a "string", a TextBox or a RichTextBox.
> If it is from a RichTextBox i want to preserve all the formatting.
>
> Public Function CryptoEasy(sPlaintext As String) As String
> '
> ' Same routine to encrypt and decrypt
> On Error GoTo CryptoEasyErr
>
> Dim n As Long
> Dim C As Long
>
> CryptoEasy = StrReverse(sPlaintext)
> For n = 1 To Len(CryptoEasy)
> C = Asc(Mid$(CryptoEasy, n, 1))
>
> Mid$(CryptoEasy, n, 1) = Chr$(C)
>
> If C > 32 Then
> If C > 127 Then
> C = 383 - C
> Else
> C = 160 - C
> End If
> Mid$(CryptoEasy, n, 1) = Chr$(C)
> End If
> Next
>
> CryptoEasyExit:
> Exit Function
>
> CryptoEasyErr:
> Debug.Assert False
> 'Resume
> Resume CryptoEasyExit
>
> End Function 'CryptoEasy
>


From: Mike B on
By the By, if you are going for just "simple", why not just use ROT13?

"Bee" <Bee(a)discussions.microsoft.com> wrote in message
news:427E1D2E-2405-4406-984F-6B0EBF0E4B22(a)microsoft.com...
>I am fiddling with this piece of code i got from someplace. I can't
>remember
> where. Some time ago. Thanks to whomever for the snippet.
>
> It works for pure ASCII text that I have tried.
> I am trying to get it to work on .RTF text but I do not understand enough
> to
> get it going.
> Someone please show me how to do this.
> If this is not possible, then what is another fast method.
> This is only for a paragraph or so of text.
>
> The text may be coming from a "string", a TextBox or a RichTextBox.
> If it is from a RichTextBox i want to preserve all the formatting.
>
> Public Function CryptoEasy(sPlaintext As String) As String
> '
> ' Same routine to encrypt and decrypt
> On Error GoTo CryptoEasyErr
>
> Dim n As Long
> Dim C As Long
>
> CryptoEasy = StrReverse(sPlaintext)
> For n = 1 To Len(CryptoEasy)
> C = Asc(Mid$(CryptoEasy, n, 1))
>
> Mid$(CryptoEasy, n, 1) = Chr$(C)
>
> If C > 32 Then
> If C > 127 Then
> C = 383 - C
> Else
> C = 160 - C
> End If
> Mid$(CryptoEasy, n, 1) = Chr$(C)
> End If
> Next
>
> CryptoEasyExit:
> Exit Function
>
> CryptoEasyErr:
> Debug.Assert False
> 'Resume
> Resume CryptoEasyExit
>
> End Function 'CryptoEasy
>


From: Bee on
Crypto is much more than I want or need.
Something simple like my example.

"Mike B" wrote:

> About 5 or 6 years ago I used this module written by Barry Dunne. I haven't
> used it since, but at the time it was pretty easy to implement, so it begs
> to be not reinvented.
>
> http://www.codeguru.com/forum/archive/index.php/t-14588.html
>
>
> "Bee" <Bee(a)discussions.microsoft.com> wrote in message
> news:427E1D2E-2405-4406-984F-6B0EBF0E4B22(a)microsoft.com...
> >I am fiddling with this piece of code i got from someplace. I can't
> >remember
> > where. Some time ago. Thanks to whomever for the snippet.
> >
> > It works for pure ASCII text that I have tried.
> > I am trying to get it to work on .RTF text but I do not understand enough
> > to
> > get it going.
> > Someone please show me how to do this.
> > If this is not possible, then what is another fast method.
> > This is only for a paragraph or so of text.
> >
> > The text may be coming from a "string", a TextBox or a RichTextBox.
> > If it is from a RichTextBox i want to preserve all the formatting.
> >
> > Public Function CryptoEasy(sPlaintext As String) As String
> > '
> > ' Same routine to encrypt and decrypt
> > On Error GoTo CryptoEasyErr
> >
> > Dim n As Long
> > Dim C As Long
> >
> > CryptoEasy = StrReverse(sPlaintext)
> > For n = 1 To Len(CryptoEasy)
> > C = Asc(Mid$(CryptoEasy, n, 1))
> >
> > Mid$(CryptoEasy, n, 1) = Chr$(C)
> >
> > If C > 32 Then
> > If C > 127 Then
> > C = 383 - C
> > Else
> > C = 160 - C
> > End If
> > Mid$(CryptoEasy, n, 1) = Chr$(C)
> > End If
> > Next
> >
> > CryptoEasyExit:
> > Exit Function
> >
> > CryptoEasyErr:
> > Debug.Assert False
> > 'Resume
> > Resume CryptoEasyExit
> >
> > End Function 'CryptoEasy
> >
>
>
> .
>
From: bitshifter on
On Sun, 14 Mar 2010 18:18:26 -0400, "Mike B"
<mDotByerley(a)VerizonDottieNettie> wrote:

>By the By, if you are going for just "simple", why not just use ROT13?

Really confuse them, use ROT0

>"Bee" <Bee(a)discussions.microsoft.com> wrote in message
>news:427E1D2E-2405-4406-984F-6B0EBF0E4B22(a)microsoft.com...
>>I am fiddling with this piece of code i got from someplace. I can't
>>remember
>> where. Some time ago. Thanks to whomever for the snippet.
>>
>> It works for pure ASCII text that I have tried.
>> I am trying to get it to work on .RTF text but I do not understand enough
>> to
>> get it going.
>> Someone please show me how to do this.
>> If this is not possible, then what is another fast method.
>> This is only for a paragraph or so of text.
>>
>> The text may be coming from a "string", a TextBox or a RichTextBox.
>> If it is from a RichTextBox i want to preserve all the formatting.
>>
>> Public Function CryptoEasy(sPlaintext As String) As String
>> '
>> ' Same routine to encrypt and decrypt
>> On Error GoTo CryptoEasyErr
>>
>> Dim n As Long
>> Dim C As Long
>>
>> CryptoEasy = StrReverse(sPlaintext)
>> For n = 1 To Len(CryptoEasy)
>> C = Asc(Mid$(CryptoEasy, n, 1))
>>
>> Mid$(CryptoEasy, n, 1) = Chr$(C)
>>
>> If C > 32 Then
>> If C > 127 Then
>> C = 383 - C
>> Else
>> C = 160 - C
>> End If
>> Mid$(CryptoEasy, n, 1) = Chr$(C)
>> End If
>> Next
>>
>> CryptoEasyExit:
>> Exit Function
>>
>> CryptoEasyErr:
>> Debug.Assert False
>> 'Resume
>> Resume CryptoEasyExit
>>
>> End Function 'CryptoEasy
>>
>
>

 |  Next  |  Last
Pages: 1 2
Prev: float inexact result
Next: Spritley Old Guy