Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. Security features

Security features

Scheduled Pinned Locked Moved Visual Studio
tutorialsecurityhelp
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James R Opdycke II
    wrote on last edited by
    #1

    I was tasked in my schooling with adding security features to a calculator code we wrote for a previous project. I have never used security features before and have not the first idea how to incorporate them in my project. We apparently have to add them to our functions (plus, minus, multiply, divide). I'm not asking for anyone to do the work for me but I could use help with what exactly needs to be done. The following is an example of the code for the button that divides:

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles divNum.Click
    ansBox.Text = (Integer.Parse(numBox1.Text) / Integer.Parse(numBox2.Text)).ToString()
    End Sub

    If more of the program is needed or anything just let me know. Any help would be amazing!

    Richard DeemingR 1 Reply Last reply
    0
    • J James R Opdycke II

      I was tasked in my schooling with adding security features to a calculator code we wrote for a previous project. I have never used security features before and have not the first idea how to incorporate them in my project. We apparently have to add them to our functions (plus, minus, multiply, divide). I'm not asking for anyone to do the work for me but I could use help with what exactly needs to be done. The following is an example of the code for the button that divides:

      Private Sub Button4_Click(sender As Object, e As EventArgs) Handles divNum.Click
      ansBox.Text = (Integer.Parse(numBox1.Text) / Integer.Parse(numBox2.Text)).ToString()
      End Sub

      If more of the program is needed or anything just let me know. Any help would be amazing!

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      What do you mean by "security features"?


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J 2 Replies Last reply
      0
      • Richard DeemingR Richard Deeming

        What do you mean by "security features"?


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        J Offline
        J Offline
        James R Opdycke II
        wrote on last edited by
        #3

        Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).

        M L J 3 Replies Last reply
        0
        • Richard DeemingR Richard Deeming

          What do you mean by "security features"?


          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

          J Offline
          J Offline
          James R Opdycke II
          wrote on last edited by
          #4

          I guess it's anything I can add to my code to make it more secure

          1 Reply Last reply
          0
          • J James R Opdycke II

            Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).

            M Offline
            M Offline
            Matt T Heffron
            wrote on last edited by
            #5

            Other than being in VB instead of c# I don't see anything to change in the code you've shown. ;) Seriously: From the wording, it looks like the issue is the accessibility of the various variables and methods in the implementation of your program. Make sure everything has the most restrictive accessibility (public/internal/protected/private) that still allows it to function correctly. Then look at things that aren't private and think about how you could redesign your code to reduce their "exposure". I'd suggest you avoid modifying the accessibility of any code generated by the designer, lest you confuse the designer.

            1 Reply Last reply
            0
            • J James R Opdycke II

              Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              As Matt says, this has nothing to do with security; it's a pity your teacher does not understand that.

              Use the best guess

              J 1 Reply Last reply
              0
              • L Lost User

                As Matt says, this has nothing to do with security; it's a pity your teacher does not understand that.

                Use the best guess

                J Offline
                J Offline
                James R Opdycke II
                wrote on last edited by
                #7

                He left this piece of python code as an example for the assignment but idk where in the code it has the security feature. From everything I have found all of my code says private on it so if that's what he wants it should have been already done lol #!/usr/bin/python # from Tkinter import * # Download this from http://www.manning.com/grayson/ from tkMessageBox import * # Download this from http://www.manning.com/grayson/ # Calculator is a class derived from Frame. Frames, being someone generic, # make a nice base class for whatever you what to create. class Calculator(Frame): # Create and return a packed frame. def frame(this, side): w = Frame(this) w.pack(side=side, expand=YES, fill=BOTH) return w # Create and return a button. def button(this, root, side, text, command=None): w = Button(root, text=text, command=command) w.pack(side=side, expand=YES, fill=BOTH) return w # Enter a digit. need_clr = False def digit(self, digit): if self.need_clr: self.display.set('') self.need_clr = False self.display.set(self.display.get() + digit) # Change sign. def sign(self): need_clr = False cont = self.display.get() if len(cont) > 0 and cont[0] == '-': self.display.set(cont[1:]) else: self.display.set('-' + cont) # Decimal def decimal(self): self.need_clr = False cont = self.display.get() lastsp = cont.rfind(' ') if lastsp == -1: lastsp = 0 if cont.find('.',lastsp) == -1: self.display.set(cont + '.') # Push a function button. def oper(self, op): self.display.set(self.display.get() + ' ' + op + ' ') self.need_clr = False # Calculate the expressoin and set the result. def calc(self): try: self.display.set(`eval(self.display.get())`) self.need_clr = True except: showerror('Operation Error', 'Illegal Operation') self.display.set('') self.need_clr = False def __init__(self): Frame.__init__(self) self.option_add('*Font', 'Verdana 12 bold') self.pack(expand=YES, fill=BOTH) self.master.title('Simple Calculator') # The StringVar() object holds the value of the Entry. self.display = StringVar() e = Entry(self, relief=SUNKEN, textvaria

                L 1 Reply Last reply
                0
                • J James R Opdycke II

                  Here is my teachers exact wording of the assignment. The GUI interface for your calculator now needs additional functions. To add security functions address the following in your Visual Studio file: Program at least one of the functions (add, subtract, multiple or divide) in your calculator program to include a security feature. An example of a security feature is to declare a variable as "private" as opposed to "public" (conduct some independent research if necessary to refresh on these topics).

                  J Offline
                  J Offline
                  James R Opdycke II
                  wrote on last edited by
                  #8

                  This is a visual basic calculator code he also gave as an example: Public Class Form1 Private Sub calculateBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateBtn.Click Dim number1 As Double Dim number2 As Double Dim answer As Double If input1TextBox.Text = "" OrElse input2TextBox.Text = "" Then MessageBox.Show("Please Enter a Number") ElseIf additionRb.Checked = False And subtractRb.Checked = False And multiplyRb.Checked = False And divideRb.Checked = False Then MessageBox.Show("Please Choose an Operation") Else number1 = Double.Parse(input1TextBox.Text) number2 = Double.Parse(input2TextBox.Text) If additionRb.Checked = True Then answer = number1 + number2 answerLbl.Text = answer.ToString() ElseIf subtractRb.Checked = True Then answer = number1 - number2 answerLbl.Text = answer.ToString() ElseIf multiplyRb.Checked = True Then If number1 = 0 OrElse number2 = 0 Then answerLbl.Text = "0" Else answer = number1 * number2 answerLbl.Text = answer.ToString() End If ElseIf divideRb.Checked = True Then If number1 = 0 Then answerLbl.Text = "0" ElseIf number2 = 0 Then answerLbl.Text = "Cannot Divide by Zero" Else answer = number1 / number2 answerLbl.Text = answer.ToString() End If End If End If End Sub End Class

                  1 Reply Last reply
                  0
                  • J James R Opdycke II

                    He left this piece of python code as an example for the assignment but idk where in the code it has the security feature. From everything I have found all of my code says private on it so if that's what he wants it should have been already done lol #!/usr/bin/python # from Tkinter import * # Download this from http://www.manning.com/grayson/ from tkMessageBox import * # Download this from http://www.manning.com/grayson/ # Calculator is a class derived from Frame. Frames, being someone generic, # make a nice base class for whatever you what to create. class Calculator(Frame): # Create and return a packed frame. def frame(this, side): w = Frame(this) w.pack(side=side, expand=YES, fill=BOTH) return w # Create and return a button. def button(this, root, side, text, command=None): w = Button(root, text=text, command=command) w.pack(side=side, expand=YES, fill=BOTH) return w # Enter a digit. need_clr = False def digit(self, digit): if self.need_clr: self.display.set('') self.need_clr = False self.display.set(self.display.get() + digit) # Change sign. def sign(self): need_clr = False cont = self.display.get() if len(cont) > 0 and cont[0] == '-': self.display.set(cont[1:]) else: self.display.set('-' + cont) # Decimal def decimal(self): self.need_clr = False cont = self.display.get() lastsp = cont.rfind(' ') if lastsp == -1: lastsp = 0 if cont.find('.',lastsp) == -1: self.display.set(cont + '.') # Push a function button. def oper(self, op): self.display.set(self.display.get() + ' ' + op + ' ') self.need_clr = False # Calculate the expressoin and set the result. def calc(self): try: self.display.set(`eval(self.display.get())`) self.need_clr = True except: showerror('Operation Error', 'Illegal Operation') self.display.set('') self.need_clr = False def __init__(self): Frame.__init__(self) self.option_add('*Font', 'Verdana 12 bold') self.pack(expand=YES, fill=BOTH) self.master.title('Simple Calculator') # The StringVar() object holds the value of the Entry. self.display = StringVar() e = Entry(self, relief=SUNKEN, textvaria

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    Well I know nothing about python; and you posted this question in the Visual Studio forum. However, and more relevant, there is nothing you can do to a calculator to make it secure, even if we really understood what that is supposed to mean. Go back and talk to your teacher and get a better explanation of what problem you are supposed to be addressing.

                    Use the best guess

                    J 1 Reply Last reply
                    0
                    • L Lost User

                      Well I know nothing about python; and you posted this question in the Visual Studio forum. However, and more relevant, there is nothing you can do to a calculator to make it secure, even if we really understood what that is supposed to mean. Go back and talk to your teacher and get a better explanation of what problem you are supposed to be addressing.

                      Use the best guess

                      J Offline
                      J Offline
                      James R Opdycke II
                      wrote on last edited by
                      #10

                      I will. Thanks anyway!

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups