VB icon

Public Encryption

Email
Submitted on: 9/8/2018 11:03:36 AM
By: Mhadz Hawaan  
Level: Intermediate
User Rating: Unrated
Compatibility: VB 6.0
Views: 950
 
     I posted this code because I need somebody who could explains every single line of this code. Thanks a lot.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Public Encryption
' Description:I posted this code because I need somebody who could explains every single line of this code.
Thanks a lot.
' By: Mhadz Hawaan
'**************************************

Public Function RndCrypt(ByVal Str As String, ByVal Password As String) As String
Dim SK As Long, K As Long
Rnd -1
Randomize Len(Password)
 
For K = 1 To Len(Password)
SK = SK + (((K Mod 256) Xor Asc(Mid$(Password, K, 1))) Xor Fix(256 * Rnd))
Next K
Rnd -1
Randomize SK
For K = 1 To Len(Str)
Mid$(Str, K, 1) = Chr(Fix(256 * Rnd) Xor Asc(Mid$(Str, K, 1)))
Next K
RndCrypt = Str
 
End Function


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

9/8/2018 1:26:59 PMJohn Korejwa

There are only a few VB functions, which can be looked up pretty easily, so it's not difficult to explain every line. This function uses VB's Rnd() function (which is essentially a 24 bit linear congruential generator) for a stream cipher. In most cases, 3 bytes of known plaintext is enough to (almost instantly) deduce the initial state, from which you can decrypt the rest of the stream and any other ciphertext encrypted with the same password.
(If this comment was disrespectful, please report it.)

 
9/9/2018 12:59:53 AMPaul Bahlawan

The secret is the same seed (randomize) will make the same sequence of "random" numbers every time. But in the end it's just a weak xor cipher.
(If this comment was disrespectful, please report it.)

 
9/9/2018 11:59:15 AMJJ Banks

If you think about security etc, it does not send anything out to the internet..
It save nothing to your harddrive either.
(If this comment was disrespectful, please report it.)

 
9/11/2018 5:22:10 AMICE

sorry my response was over the 1000 char limit & could not be posted, even though it was thorough. I hate having limited texts lol, I'll try another way to get it to you,
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.