Results 1 to 3 of 3

Thread: modulus reversal and counting integers

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    2

    Question

    How do you reverse the calculation imposed by a modulus symbol? ie if you encrypt by (number + 7) Mod 10 in an encryption program, how could one write a separate decryption program that accepts an encrypted number and decrypts it back to its original state?

    Additionally - how could one code a program that reads in a 1-5 digit integer in a singular textbox then total and print the amount of number 7's typed into the text box?

    please help

    F

    [email protected]

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151

    Mid Function.

    Put data from text box into a string and use Mid Function in a For loop to examine the individual digits.

    It is not clear what you mean by (Number + 7) Mod ten. Is the Mod function applied to each digit of a long decimal number? Is it applied to byte data?
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    'limits textbox to 5 characters
    Private Sub Text1_Change()
        If Len(Text1) > 5 Then Text1 = Left(Text1, 5)
    End Sub
    
    'count 7'ns in a tetbox
    a=instr(text1,"7")
    Do while a
      count=count+1
      a=instr(a+1,text1,"7")
    loop
    Using mod for a encryption isn't a too bright idea, you have to be sure to have an individual result for each number, otherways you can't decrypt it, if you pass a number trough (number+7) mod 10 number has to be a integer from X to X+9.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width