zRanP - Randomly generate passwords (.NET)

NightCrawler03X NightCrawler03X is offline Offline Feb 13th, 2009, 2:13 pm |
0
I've also posted this on programmingforums: http://www.programmingforums.org/thread20557-4.html

Screenshot:
http://i59.photobucket.com/albums/g2...03X/zranp2.png

As it says in the title, zRanP is a program to randomly generate secure passwords of varying lengths (of which are defined by you, the user). zRanP can either generate from ascii characters 33 to 126 (excluding ascii char 34, which is the space character), or generate only alphanumerals or symbols seperately on their own; with each new generated password, a strength meter will inform you of how strong that password is. In addition to randomly generating passwords, you can also type in any other password, and as you type, the strength meter will change according to what you've typed so far.

I am releasing both the full source code (project and all), and a compiled executable. zRanP is written by myself in VB.NET 2008, so you will need the latest version of the .NET framework installed in order to make use of it.

In using zRanP, you agree to the license quoted below (don't worry, it basically lets you do anything you like with this software. I've only put a copyright on it so that I can include a legal disclaimer in order to protect my ass. But do read the license so that you know and understand your rights).
' zRanP, written by NightCrawler03X
' Copyright (C) 2009 NightCrawler03X, All Rights Reserved
' In regards to this software, permission to use, copy, modify, reproduce, redistribute (under the definitions of international copyright law),
' is hereby granted, but the above copyright notice must remain, and the following disclaimer applies:
'' ''THIS SOFTWARE IS PROVIDED ''AS IS'', AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
'' ''THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
'' ''THE COPYRIGHT HOLDER OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
'' ''BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERUPTION)
'' ''HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
'' ''(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
'' ''OF SUCH DAMAGE.

'' Should you have any questions, direct them to nightcrawler03x@gmail.com
'' You may also find me under the following aliases at the following forums (just sign up and send me a private message):
'' zerohero (http://forums.xkcd.com),
'' NightCrawler03X (http://www.ubuntuforums.org, http://www.programmingforums.org, http://www.daniweb.com)
To-do in the future:
- Make it possible to save these passwords to a plain text file or some kind of database, for later reference (obviously some of the passwords generated will be a little too difficult to remember)
- With the aid of a dictionary list, check in each password string generated for any words that appear in a dictionary.
- Check against each string generated to see if all four sets are present (uppercase, lowercase, numbers, and symbols), and at the user's control, decide upon whether to display these passwords. I.e. if the user wants all four sets, that user will get it.

For those who want to quickly take a peek at the source code before downloading, here it is:
  1. ' zRanP, written by NightCrawler03X
  2. ' Copyright (C) 2009 NightCrawler03X, All Rights Reserved
  3. ' In regards to this software, permission to use, copy, modify, reproduce, redistribute (under the definitions of international copyright law),
  4. ' is hereby granted, but the above copyright notice must remain, and the following disclaimer applies:
  5. '' ''THIS SOFTWARE IS PROVIDED ''AS IS'', AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  6. '' ''THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  7. '' ''THE COPYRIGHT HOLDER OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  8. '' ''BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERUPTION)
  9. '' ''HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10. '' ''(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  11. '' ''OF SUCH DAMAGE.
  12.  
  13. '' Should you have any questions, direct them to nightcrawler03x@gmail.com
  14. '' You may also find me under the following aliases at the following forums (just sign up and send me a private message):
  15. '' zerohero (http://forums.xkcd.com),
  16. '' NightCrawler03X (http://www.ubuntuforums.org, http://www.programmingforums.org, http://www.daniweb.com)
  17. Public Class zGenP
  18.  
  19. Private omitSymbols As Boolean = False
  20. Private omitAlpha As Boolean = False
  21.  
  22. Private Function generatePassword(ByRef minLength As Integer, ByRef maxLength As Integer, _
  23. ByRef disableSymbols As Boolean, ByRef disableAlpha As Boolean) As String
  24. Dim s As String = "" : Dim passwordLength As Integer = 0 : generatePassword = ""
  25. Do : Randomize() : passwordLength = Convert.ToInt32(minLength + Int(Rnd() * (maxLength - minLength)))
  26. Loop Until passwordLength >= minLength
  27. For i As Integer = 1 To passwordLength Step 1 : Randomize()
  28. Do : Do : Do : s = Chr(Convert.ToInt32(33 + Int(Rnd() * 94)))
  29. Loop Until Not s = Chr(34)
  30. If disableSymbols And (s Like "#" Or Not qChr(s) = 0) Then Exit Do _
  31. Else If Not disableSymbols Then Exit Do
  32. Loop
  33. If disableAlpha And Not (s Like "#" Or Not qChr(s) = 0) Then Exit Do _
  34. Else If Not disableAlpha Then Exit Do
  35. Loop : generatePassword += s : Next
  36. End Function
  37.  
  38. Private Function strengthPassword(ByRef s As String) As String
  39. Dim aPos As Integer = 0
  40. If boolAZ(s) Then aPos += 1
  41. If chrSort(s) Then aPos += 1
  42. If qwertySort(s) Then aPos += 1
  43. If s.Length >= 12 Then aPos += 1
  44. Select Case aPos : Case 0 : Return "pathetic" : Case 1 : Return "weak"
  45. Case 2 : Return "medium" : Case 3 : Return "strong"
  46. Case 4 : Return "very strong" : End Select : Return "?strength?"
  47. End Function
  48.  
  49. Private Function boolAZ(ByRef s As String) As Boolean
  50. Dim iCaps As Integer = 0 : Dim iLowers As Integer = 0 : Dim iDigits As Integer = 0
  51. For j As Integer = 1 To s.Length Step 1
  52. Dim iTemp As Integer = System.Convert.ToInt32(System.Convert.ToChar(Mid(s, j, 1)))
  53. If iTemp >= 65 And iTemp <= 90 Then iCaps += 1 _
  54. Else If iTemp >= 97 And iTemp <= 122 Then iLowers += 1 _
  55. Else If iTemp >= 48 And iTemp <= 57 Then iDigits += 1
  56. Next
  57. If iCaps >= 2 And iLowers >= 2 And iDigits >= 2 Then Return True
  58. Return False
  59. End Function
  60.  
  61. Private Function qChr(ByRef s As String) As Integer
  62. Select Case s.ToLower
  63. Case "q" : Return 1 : Case "w" : Return 2 : Case "e" : Return 3 : Case "r" : Return 4
  64. Case "t" : Return 5 : Case "y" : Return 6 : Case "u" : Return 7 : Case "i" : Return 8
  65. Case "o" : Return 9 : Case "p" : Return 10 : Case "a" : Return 11 : Case "s" : Return 12
  66. Case "d" : Return 13 : Case "f" : Return 14 : Case "g" : Return 15 : Case "h" : Return 16
  67. Case "j" : Return 17 : Case "k" : Return 18 : Case "l" : Return 19 : Case "z" : Return 20
  68. Case "x" : Return 21 : Case "c" : Return 22 : Case "v" : Return 23 : Case "b" : Return 24
  69. Case "n" : Return 25 : Case "m" : Return 26 : Case Else : Return 0 : End Select
  70. End Function
  71.  
  72. Private Function qwertySort(ByRef s As String) As Boolean
  73. Dim iTemp As Integer = 0 : Dim sRel As String = extractAZ(s)
  74. For i As Integer = 1 To sRel.Length - 1 Step 1
  75. For j As Integer = 1 To sRel.Length - 1 Step 1
  76. If qChr(Mid(sRel, j, 1)) > qChr(Mid(sRel, j + 1, 1)) Then
  77. iTemp += 1 : Dim sTemp As String = Mid(extractAZ(s), j, 1)
  78. Mid(sRel, j, 1) = Mid(extractAZ(s), j + 1, 1) : Mid(sRel, j + 1, 1) = sTemp
  79. End If : Next : Next
  80. If iTemp >= sRel.Length Then Return True Else Return False
  81. End Function
  82.  
  83. Private Function chrSort(ByRef s As String) As Boolean
  84. Dim iTemp As Integer = 0
  85. For i As Integer = 1 To s.Length - 1 Step 1
  86. For j As Integer = 1 To s.Length - 1 Step 1
  87. If System.Convert.ToInt32(System.Convert.ToChar(Mid(s, j, 1))) _
  88. > System.Convert.ToInt32(Convert.ToChar(Mid(s, j + 1, 1))) Then
  89. iTemp += 1 : Dim sTemp As String = Mid(s, j, 1)
  90. Mid(s, j, 1) = Mid(s, j + 1, 1) : Mid(s, j + 1, 1) = sTemp
  91. End If : Next : Next
  92. If iTemp >= s.Length Then Return True Else Return False
  93. End Function
  94.  
  95. Private Function extractAZ(ByRef s As String) As String
  96. extractAZ = "" : For i As Integer = 1 To s.Length Step 1
  97. If Mid(s, i, 1).ToLower Like "[a-f]" Then extractAZ += Mid(s, i, 1)
  98. Next
  99. End Function
  100.  
  101. Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
  102. Try : If cboOmitSym.Checked Then omitSymbols = True Else omitSymbols = False
  103. If cboOmitAlpha.Checked Then omitAlpha = True Else omitAlpha = False
  104. If Convert.ToInt32(cboMin.Text) > Convert.ToInt32(cboOut.Text) Then
  105. txtOutput.Text = "ERROR: Minimum length is amove maximum"
  106. txtStrength.Text = ""
  107. ElseIf cboOmitAlpha.Checked And cboOmitSym.Checked Then
  108. txtOutput.Text = "ERROR: Both checkboxes are checked"
  109. txtStrength.Text = ""
  110. Else
  111. txtOutput.Text = generatePassword(Convert.ToInt32(cboMin.Text), Convert.ToInt32(cboOut.Text), omitSymbols, omitAlpha)
  112. End If
  113. Catch ex As Exception : txtOutput.Text = "ERROR: Minimum or maximum cannot be null"
  114. txtStrength.Text = "" : End Try
  115. End Sub
  116.  
  117. Private Sub zGenP_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  118. For i As Integer = 4 To 48 Step 4
  119. cboMin.Items.Add(i.ToString) : cboOut.Items.Add(i.ToString) : Next
  120. cboMin.SelectedIndex = 0 : cboOut.SelectedIndex = 0
  121. End Sub
  122.  
  123. Private Sub txtOutput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOutput.TextChanged
  124. Dim sTemp As String = txtOutput.Text
  125. txtStrength.Text = strengthPassword(sTemp)
  126. End Sub
  127.  
  128. Private Sub cboMin_KeyPress(ByVal sender As Object, _
  129. ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboMin.KeyPress
  130. If e.KeyChar.ToString Like "#" Or e.KeyChar.ToString = Chr(8) Then
  131. Else : e.KeyChar = Nothing : End If
  132. End Sub
  133.  
  134. Private Sub cboOut_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboOut.KeyPress
  135. If e.KeyChar.ToString Like "#" Or e.KeyChar.ToString = Chr(8) Then
  136. Else : e.KeyChar = Nothing : End If
  137. End Sub
  138.  
  139. Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
  140. End
  141. End Sub
  142.  
  143. End Class

Files to download are attached below:
Last edited by NightCrawler03X; Feb 13th, 2009 at 2:36 pm.
Quick reply to this message  
Attached Files
File Type: zip zRanP_006_source.zip (171.5 KB, 1 views)
File Type: zip zRanP_006_executable.zip (13.3 KB, 0 views)
0
Ehsan_Y Ehsan_Y is offline Offline | Feb 13th, 2009
Hi . thanks for file
Quick reply to this message  
0
NightCrawler03X NightCrawler03X is offline Offline | Feb 14th, 2009
New version:

Screenshots:
http://i59.photobucket.com/albums/g2...p_007_save.png
http://i59.photobucket.com/albums/g2...p_007_load.png

New features:
- Save/Load: The size of the window increases when "Load" is checked, making room for the textbox where the loaded file content is written to, and upon clicking the load button, the contents of the file are displayed in the textbox. The size of the window returns to it's default when "save" is checked. *
- In addition to the above, I have also somewhat cleaned up some code

* keep note that the passwords are written to plain text files. This means that absolutely anyone can read them. I would try to encrypt these files, but unfortunately I do not yet know how to do that. However, there is an excellent (open-source, and available free of charge) utility called "TrueCrypt" --> http://www.truecrypt.org. I recommend using truecrypt to make a virtual volume, encrypt it, and set a password on it ( heh, try one of the "very strong" passwords that zRanP generates ). Upon creating this virtual volume, you can then mount it like a real hard disc, and access it as a regular drive letter via windows explorer; if you want to keep these stored passwords secure, store it in that virtual, encrypted volume.
As for actual encryption/hashing, I recommend AES-256 encryption, and RIPEMD-160 hashing; but of course, I leave the choice up to you. Twofish encryption and SHA-512 hashing is also a good choice.

Here is the source code, in case you want to take a look before downloading:
  1. ' zRanP, written by NightCrawler03X
  2. ' Copyright (C) 2009 NightCrawler03X, All Rights Reserved
  3. ' In regards to this software, permission to use, copy, modify, reproduce, redistribute (under the definitions of international copyright law),
  4. ' is hereby granted, but the above copyright notice must remain, and the following disclaimer applies:
  5. '' ''THIS SOFTWARE IS PROVIDED ''AS IS'', AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  6. '' ''THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  7. '' ''THE COPYRIGHT HOLDER OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  8. '' ''BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERUPTION)
  9. '' ''HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10. '' ''(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  11. '' ''OF SUCH DAMAGE.
  12.  
  13. '' Should you have any questions, direct them to nightcrawler03x@gmail.com
  14. '' You may also find me under the following aliases at the following forums (just sign up and send me a private message):
  15. '' zerohero (http://forums.xkcd.com),
  16. '' NightCrawler03X (http://www.ubuntuforums.org, http://www.programmingforums.org, http://www.daniweb.com)
  17. Public Class zGenP
  18.  
  19. Private omitSymbols As Boolean = False
  20. Private omitAlpha As Boolean = False
  21.  
  22. Private Function generatePassword(ByRef minLength As Integer, ByRef maxLength As Integer, _
  23. ByRef disableSymbols As Boolean, ByRef disableAlpha As Boolean) As String
  24. Dim s As String = "" : Dim passwordLength As Integer = 0 : generatePassword = ""
  25. Do : Randomize() : passwordLength = Convert.ToInt32(minLength + Int(Rnd() * (maxLength - minLength)))
  26. Loop Until passwordLength >= minLength : For i As Integer = 1 To passwordLength Step 1 : Randomize()
  27. Do : Do : Do : s = Chr(Convert.ToInt32(33 + Int(Rnd() * 94)))
  28. Loop Until Not s = Chr(34)
  29. Loop Until (disableSymbols And (s Like "#" Or Not qChr(s) = 0)) Or Not disableSymbols
  30. Loop Until (disableAlpha And Not (s Like "#" Or Not qChr(s) = 0)) Or Not disableAlpha : generatePassword += s : Next
  31. End Function
  32.  
  33. Private Function strengthPassword(ByRef s As String) As String
  34. Dim i As Integer = 0
  35. If boolAZ(s) Then i += 1 : If chrSort(s) Then i += 1
  36. If qwertySort(s) Then i += 1 : If s.Length >= 12 Then i += 1
  37. Select Case i
  38. Case 0 : Return "pathetic" : Case 1 : Return "weak"
  39. Case 2 : Return "medium" : Case 3 : Return "strong"
  40. Case 4 : Return "very strong" : End Select
  41. End Function
  42.  
  43. Private Function qChr(ByRef s As String) As Integer
  44. Select Case s.ToLower
  45. Case "q" : Return 1 : Case "w" : Return 2 : Case "e" : Return 3
  46. Case "r" : Return 4 : Case "t" : Return 5 : Case "y" : Return 6
  47. Case "u" : Return 7 : Case "i" : Return 8 : Case "o" : Return 9
  48. Case "p" : Return 10 : Case "a" : Return 11 : Case "s" : Return 12
  49. Case "d" : Return 13 : Case "f" : Return 14 : Case "g" : Return 15
  50. Case "h" : Return 16 : Case "j" : Return 17 : Case "k" : Return 18
  51. Case "l" : Return 19 : Case "z" : Return 20 : Case "x" : Return 21
  52. Case "c" : Return 22 : Case "v" : Return 23 : Case "b" : Return 24
  53. Case "n" : Return 25 : Case "m" : Return 26 : Case Else : Return 0
  54. End Select
  55. End Function
  56.  
  57. Private Function extractAZ(ByRef s As String) As String
  58. extractAZ = "" : For i As Integer = 1 To s.Length Step 1
  59. If Mid(s, i, 1).ToLower Like "[a-f]" Then extractAZ += Mid(s, i, 1)
  60. Next
  61. End Function
  62.  
  63. Private Function qwertySort(ByRef s As String) As Boolean
  64. Dim iTemp As Integer = 0 : Dim sRel As String = extractAZ(s)
  65. For i As Integer = 1 To sRel.Length - 1 Step 1
  66. For j As Integer = 1 To sRel.Length - 1 Step 1
  67. If qChr(Mid(sRel, j, 1)) > qChr(Mid(sRel, j + 1, 1)) Then
  68. iTemp += 1 : Dim sTemp As String = Mid(extractAZ(s), j, 1)
  69. Mid(sRel, j, 1) = Mid(extractAZ(s), j + 1, 1) : Mid(sRel, j + 1, 1) = sTemp
  70. End If : Next : Next
  71. If iTemp >= sRel.Length Then Return True Else Return False
  72. End Function
  73.  
  74. Private Function chrSort(ByRef s As String) As Boolean
  75. Dim iTemp As Integer = 0 : For i As Integer = 1 To s.Length - 1 Step 1
  76. For j As Integer = 1 To s.Length - 1 Step 1
  77. If System.Convert.ToInt32(System.Convert.ToChar(Mid(s, j, 1))) _
  78. > System.Convert.ToInt32(Convert.ToChar(Mid(s, j + 1, 1))) Then
  79. iTemp += 1 : Dim sTemp As String = Mid(s, j, 1)
  80. Mid(s, j, 1) = Mid(s, j + 1, 1) : Mid(s, j + 1, 1) = sTemp
  81. End If : Next : Next
  82. If iTemp >= s.Length Then Return True Else Return False
  83. End Function
  84.  
  85. Private Function boolAZ(ByRef s As String) As Boolean
  86. Dim iCaps As Integer = 0 : Dim iLowers As Integer = 0 : Dim iDigits As Integer = 0
  87. For j As Integer = 1 To s.Length Step 1
  88. Dim iTemp As Integer = System.Convert.ToInt32(System.Convert.ToChar(Mid(s, j, 1)))
  89. If iTemp >= 65 And iTemp <= 90 Then iCaps += 1 _
  90. Else If iTemp >= 97 And iTemp <= 122 Then iLowers += 1 _
  91. Else If iTemp >= 48 And iTemp <= 57 Then iDigits += 1
  92. Next
  93. If iCaps >= 2 And iLowers >= 2 And iDigits >= 2 Then Return True Else Return False
  94. End Function
  95.  
  96. Private Sub btnGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGenerate.Click
  97. Try:If cboOmitSym.Checked Then omitSymbols = True Else omitSymbols = False
  98. If cboOmitAlpha.Checked Then omitAlpha = True Else omitAlpha = False
  99. If Convert.ToInt32(cboMin.Text) > Convert.ToInt32(cboOut.Text) Then
  100. txtOutput.Text = "ERROR: Minimum length is amove maximum" : txtStrength.Text = ""
  101. ElseIf cboOmitAlpha.Checked And cboOmitSym.Checked Then
  102. txtOutput.Text = "ERROR: Both checkboxes are checked" : txtStrength.Text = ""
  103. Else : txtOutput.Text = generatePassword(Convert.ToInt32(cboMin.Text), Convert.ToInt32(cboOut.Text), omitSymbols, omitAlpha) : End If
  104. Catch ex As Exception : txtOutput.Text = "ERROR: Minimum or maximum cannot be null" : txtStrength.Text = "" : End Try
  105. End Sub
  106.  
  107. Private Sub zGenP_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  108. For i As Integer = 4 To 48 Step 4 : cboMin.Items.Add(i.ToString) : cboOut.Items.Add(i.ToString) : Next
  109. cboMin.SelectedIndex = 0 : cboOut.SelectedIndex = 0
  110. txtFilePath.Text = "C:\" : rdbSave.Checked = True
  111. End Sub
  112.  
  113. Private Sub txtOutput_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtOutput.TextChanged
  114. Dim sTemp As String = txtOutput.Text : txtStrength.Text = strengthPassword(sTemp)
  115. End Sub
  116.  
  117. Private Sub cboMin_KeyPress(ByVal sender As Object, _
  118. ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cboMin.KeyPress, cboOut.KeyPress
  119. If Not (e.KeyChar.ToString Like "#" Or e.KeyChar.ToString = Chr(8)) Then e.KeyChar = Nothing
  120. End Sub
  121.  
  122. Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click
  123. End
  124. End Sub
  125.  
  126. Private Sub btnReadWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReadWrite.Click
  127. If (rdbSave.Checked And txtOutput.Text.Length > 0) And Not Mid(txtStrength.Text, 1, 1) = "E" Then
  128. Try : FileOpen(1, txtFilePath.Text, OpenMode.Append)
  129. WriteLine(1, txtOutput.Text + " " + txtStrength.Text) : FileClose(1)
  130. txtFileError.Text = "Written"
  131. Catch ex As Exception : txtFileError.Text = "Invalid Path" : End Try
  132. ElseIf rdbLoad.Checked Then : rtxtFileContent.Text = ""
  133. Try : FileOpen(1, txtFilePath.Text, OpenMode.Input)
  134. txtFileError.Text = "Loaded"
  135. Do Until EOF(1)
  136. Dim sTemp As String = "" : Input(1, sTemp)
  137. rtxtFileContent.Text &= sTemp + Chr(13) + Chr(13) : Loop
  138. FileClose(1)
  139. Catch ex As Exception : txtFileError.Text = "Invalid Path" : End Try
  140. End If
  141. End Sub
  142.  
  143. Private Sub rdbSave_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbSave.CheckedChanged
  144. txtFileError.Text = ""
  145. If rdbSave.Checked Then : rtxtFileContent.Text = Nothing
  146. Me.Size = New Size(515, 132) : btnReadWrite.Text = "Save"
  147. Else : Me.Size = New Size(515, 305)
  148. btnReadWrite.Text = "Load" : End If
  149. End Sub
  150. End Class

' zRanP, written by NightCrawler03X
' Copyright (C) 2009 NightCrawler03X, All Rights Reserved
' In regards to this software, permission to use, copy, modify, reproduce, redistribute (under the definitions of international copyright law),
' is hereby granted, but the above copyright notice must remain, and the following disclaimer applies:
'' ''THIS SOFTWARE IS PROVIDED ''AS IS'', AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
'' ''THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
'' ''THE COPYRIGHT HOLDER OF THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
'' ''BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERUPTION)
'' ''HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
'' ''(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
'' ''OF SUCH DAMAGE.

'' Should you have any questions, direct them to nightcrawler03x@gmail.com
'' You may also find me under the following aliases at the following forums (just sign up and send me a private message):
'' zerohero (http://forums.xkcd.com),
'' NightCrawler03X (http://www.ubuntuforums.org, http://www.programmingforums.org, http://www.daniweb.com)
Compiled executable and full source code included, linked below:
Last edited by NightCrawler03X; Feb 14th, 2009 at 3:41 pm.
Attached Files
File Type: zip zRanP_007_source.zip (27.3 KB, 0 views)
File Type: zip zRanP_007_executable.zip (16.6 KB, 0 views)
Quick reply to this message  
 

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC