Welcome to the North American Subaru Impreza Owners Club Sunday September 21, 2014
Home Forums WikiNASIOC Products Store Modifications Upgrade Garage
NASIOC
Here you can view your subscribed threads, work with private messages and edit your profile and preferences Home Registration is free! Visit the NASIOC Store NASIOC Rules Search Find other members Frequently Asked Questions Calendar Archive NASIOC Upgrade Garage Logout
Go Back   NASIOC > NASIOC Miscellaneous > Off-Topic

Welcome to NASIOC - The world's largest online community for Subaru enthusiasts!
Welcome to the NASIOC.com Subaru forum.

You are currently viewing our forum as a guest, which gives you limited access to view most discussions and access our other features. By joining our community, free of charge, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is free, fast and simple, so please join our community today!

If you have any problems with the registration process or your account login, please contact us.
* Registered users of the site do not see these ads.
Reply
 
Thread Tools Display Modes
Old 11-19-2004, 05:32 PM   #1
Schleppy
Scooby Specialist
 
Member#: 15858
Join Date: Feb 2002
Chapter/Region: NESIC
Location: Boston
Vehicle:
SPB

Default Math gurus, quick question...

I have this equation:
((204 + 54) mod 256) = 258 mod 256 = 2

What is the inverse of this equation? This is for the decryption part of a cryptographic algorithm. What I posted above is the encryption Basically I have 204 (my key) and 2 (the ciphertext), and I need to get that 54 (plaintext) back doing the inverse of that equation, knowing only 204 and 2. I seem to remember something about two's complement, but I can't remember for sure...

Thanks!

-S
* Registered users of the site do not see these ads.
Schleppy is offline   Reply With Quote
Old 11-19-2004, 05:36 PM   #2
kbcr3
Scooby Specialist
 
Member#: 44170
Join Date: Sep 2003
Chapter/Region: Tri-State
Location: Arlington, VA
Vehicle:
2010 Forester XT
05 and 09 honda ruckus

Default

wow, i suddenly feel really stupid. hope that makes you feel better...making me feel stupid and all... i hope you do.
kbcr3 is offline   Reply With Quote
Old 11-19-2004, 05:37 PM   #3
WRXXXual
Scooby Newbie
 
Member#: 67784
Join Date: Aug 2004
Chapter/Region: MAIC
Location: TAX HELL-Alexandria VA
Vehicle:
Now with 100% more
STI short block!

Default

it's 5
WRXXXual is offline   Reply With Quote
Old 11-19-2004, 05:38 PM   #4
need2speed
Scooby Newbie
 
Member#: 68768
Join Date: Aug 2004
Location: Cataluña
Default

need2speed is offline   Reply With Quote
Old 11-19-2004, 05:39 PM   #5
WRXXXual
Scooby Newbie
 
Member#: 67784
Join Date: Aug 2004
Chapter/Region: MAIC
Location: TAX HELL-Alexandria VA
Vehicle:
Now with 100% more
STI short block!

Default

ask me when you have a question concerning partial differential equations pertaining to mechanical systems
WRXXXual is offline   Reply With Quote
Old 11-19-2004, 05:43 PM   #6
volume311
Scooby Newbie
 
Member#: 56615
Join Date: Mar 2004
Location: Hurricane central
Default

258-256=2 hope that helps
volume311 is offline   Reply With Quote
Old 11-19-2004, 05:46 PM   #7
mhoward1
Scooby Specialist
 
Member#: 9481
Join Date: Aug 2001
Chapter/Region: South East
Location: FFR Challenge #43
Vehicle:
2011 Carrera 4s
2009 BMW M5

Default

Help clarify the question, do you want to know the key if the crytotext is 2?
mhoward1 is offline   Reply With Quote
Old 11-19-2004, 05:50 PM   #8
mhoward1
Scooby Specialist
 
Member#: 9481
Join Date: Aug 2001
Chapter/Region: South East
Location: FFR Challenge #43
Vehicle:
2011 Carrera 4s
2009 BMW M5

Default

Oh, I get it now.

Mod is Modular Mathmatics, and 256 is the cycle. Think of a clock that rotates every 256 minutes.. so 258=2 or 54+204, so if the orginal is 6, the cipher value could be 6, 262, 518, etc.
mhoward1 is offline   Reply With Quote
Old 11-19-2004, 05:50 PM   #9
Kha0S
Scooby Guru
 
Member#: 8808
Join Date: Jul 2001
Chapter/Region: NESIC
Location: Grantham, NH
Vehicle:
2011 WRX (DGM 5D)
2002 WRX/2003 SVTF

Default

((ciphertext + 202) % 256)

So, (2 + 202) % 256) = (204 % 256) = 204

The trick is, you need to subtract 54, and bound the result between 0 and 256. By adding 256 to start, then subtracting (resulting in a net addition of 256 - 54 = 202), then doing your modulo, you don't end up going negative.

Understand?

/Andrew
Kha0S is offline   Reply With Quote
Old 11-19-2004, 05:54 PM   #10
IggDawg
Celebrity Guest Star
 
Member#: 10648
Join Date: Sep 2001
Chapter/Region: NESIC
Location: Sort of Boston, MA
Vehicle:
2002 Escort... D:
Mostly kind of white

Default

Quote:
Originally Posted by Kha0S
((ciphertext + 202) % 256)

So, (2 + 202) % 256) = (204 % 256) = 204

The trick is, you need to subtract 54, and bound the result between 0 and 256. By adding 256 to start, then subtracting (resulting in a net addition of 256 - 54 = 202), then doing your modulo, you don't end up going negative.

Understand?

/Andrew
LIES!
IggDawg is offline   Reply With Quote
Old 11-19-2004, 05:55 PM   #11
Kha0S
Scooby Guru
 
Member#: 8808
Join Date: Jul 2001
Chapter/Region: NESIC
Location: Grantham, NH
Vehicle:
2011 WRX (DGM 5D)
2002 WRX/2003 SVTF

Default

Quote:
Originally Posted by IggDawg
LIES!
I read it on the internet, so it must be true.

/Andrew
Kha0S is offline   Reply With Quote
Old 11-19-2004, 05:56 PM   #12
Kha0S
Scooby Guru
 
Member#: 8808
Join Date: Jul 2001
Chapter/Region: NESIC
Location: Grantham, NH
Vehicle:
2011 WRX (DGM 5D)
2002 WRX/2003 SVTF

Default

S E T E C A S T R O N O M Y
C O O T Y ' S R A T S E M E N
M O N T E R E Y ' S C O A S T
Kha0S is offline   Reply With Quote
Old 11-19-2004, 05:59 PM   #13
Subystud
Scooby Newbie
 
Member#: 57943
Join Date: Mar 2004
Chapter/Region: South East
Location: Tampa, Florida
Vehicle:
WRX Stage 1+
Back to the basics

Default

Quote:
Originally Posted by mh_WRX
Oh, I get it now.

Mod is Modular Mathmatics, and 256 is the cycle. Think of a clock that rotates every 256 minutes.. so 258=2 or 54+204, so if the orginal is 6, the cipher value could be 6, 262, 518, etc.
So 262 is like the coterminal "angle" of 6? Does modular mathematics go in negatives? I dunno, this is as far as high-school calculus has taken me...
Subystud is offline   Reply With Quote
Old 11-19-2004, 06:00 PM   #14
mhoward1
Scooby Specialist
 
Member#: 9481
Join Date: Aug 2001
Chapter/Region: South East
Location: FFR Challenge #43
Vehicle:
2011 Carrera 4s
2009 BMW M5

Default

BTW, a better use instead of mod is a Archimedean Spiral or possible a helix.
mhoward1 is offline   Reply With Quote
Old 11-19-2004, 06:01 PM   #15
mhoward1
Scooby Specialist
 
Member#: 9481
Join Date: Aug 2001
Chapter/Region: South East
Location: FFR Challenge #43
Vehicle:
2011 Carrera 4s
2009 BMW M5

Default

Quote:
Originally Posted by Subystud
So 262 is like the coterminal "angle" of 6? Does modular mathematics go in negatives? I dunno, this is as far as high-school calculus has taken me...
No they go from 0 to the cycle value. So in this case it would just keep repeating 0-256.
mhoward1 is offline   Reply With Quote
Old 11-19-2004, 06:03 PM   #16
Kha0S
Scooby Guru
 
Member#: 8808
Join Date: Jul 2001
Chapter/Region: NESIC
Location: Grantham, NH
Vehicle:
2011 WRX (DGM 5D)
2002 WRX/2003 SVTF

Default

Quote:
Originally Posted by Subystud
So 262 is like the coterminal "angle" of 6? Does modular mathematics go in negatives? I dunno, this is as far as high-school calculus has taken me...
Depends on how you define it. Technically, yes, but in many implementations, it'll get upset with negative numbers.

Since you can avoid negatives with mod by adding the modulus first, then subtracting, it's easy to work around.

/Andrew
Kha0S is offline   Reply With Quote
Old 11-20-2004, 01:49 PM   #17
Schleppy
Scooby Specialist
 
Member#: 15858
Join Date: Feb 2002
Chapter/Region: NESIC
Location: Boston
Vehicle:
SPB

Default

Code:
      11001100  (204, the key)
      00110011  (Flip the bits)
      --------
    + 00000001  (Add 1)
    =
      00110100  (2’s complement of 204)
    + 00000010  (Add the ciphertext, 2)
    ----------
   54 00110110  (Plaintext!)
Schleppy is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Attn: Juniper router gurus, quick question chkltcow Off-Topic 10 02-28-2007 01:20 PM
OT web gurus....quick question about HTML.. GooseMan Off-Topic 5 06-08-2006 11:34 AM
Graphic Gurus...quick question Drew888 Off-Topic 8 03-14-2005 06:01 PM
OT Computer Gurus...quick question az ej20 fan Off-Topic 5 12-15-2004 01:29 AM
Brake gurus...quick question BlueWRXagon Service & Maintenance 12 09-03-2003 04:05 PM


All times are GMT -4. The time now is 08:43 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Powered by Searchlight © 2014 Axivo Inc.
Copyright ©1999 - 2014, North American Subaru Impreza Owners Club, Inc.