Encryption/Decryption keys:

edited July 2011 in Science & Tech
Hello - I am working with image encryption and decrytion.

I am using a rand(l,m) * 10 + 1 = encryptionKey

where l,m is the dimensions of my image matrix

i am trying to multiply the encryption key to the magnitude and phase of the image - and then use a decryption key to get back to the original image.


i am not sure how to go about getting this decryption key.

i would have assumed it be

decryptionKey = inv(encryptionKey)

and then doing:

encyptionKey * magnitude of image = a

then decryptionKey * a = b


i am using fft2 to compute the magnitude and phase of the images.


pretty much - i want to multiple the magnitude and phase of the image by the encryption key and then add these 2 to make the encryptied image and then take the inverse fourier [ifft2] to get back to the original image.


please help.

thanks in advance.

Comments

  • edited July 2011
    also when multiplying the encryptionKey * magntiude of image


    would if be .*

    or *

    ?

    same question for when decrypting it.


    thanks
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited July 2011
    I don't think that's how encryption works...

    EDIT: Did you come up with this algorithm or did your professor tell you to implement your cipher this way?
  • ardichokeardichoke Icrontian
    edited July 2011
    I'm with drasnor on this. I'm pretty sure your algorithm is off.

    Also, what do you mean when you say you're going to add the encrypted magnitude and phase together? Can you even do that? Speaking from a mathematical standpoint, generally you don't use addition/subtraction when doing encryption unless you're adding/subtracting a known constant since adding/subtracting two variable values isn't possible to reverse without knowing what one of the original values is. Of course, that's strictly algebraically speaking, I'm not so familiar with phase and magnitude of images wrt how you manipulate them.

    Really though, at the end of the day, what you're asking is beyond the scope of this forum. Please read the posting guideline for this forum: http://icrontic.com/forum/showthread.php?t=91735

    If you have problems with your code, we can help. You seem to have fundamental algorithm problems which is something you need to work out on your own. I'd suggest speaking to your professor, TA or consulting the people in an appropriate learning center (if your school has them).
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited July 2011
    I spoke with shwaip regarding this last night, transcript:
    [23:31] {drasnor} my first observation is that even if he doesn't try to encipher, taking the fft of his pic and then the ifft will not yield the original
    [23:31] {drasnor} depending on the scale size, he might get an o-k approximation though
    [23:33] {drasnor} second, multiplication is a crappy cipher. he should probably be using an xor for something this simple
    [23:33] {drasnor} third, why would you encrypt the fft output and send that as ciphertext?
    [23:33] {drasnor} just taking the fft of the pic is going to make it impossible to read as a pic
    [00:17] {shwaip} dras
    [00:17] {shwaip} it really sounds like the typical post in the forums
    So maybe that's a little one-sided, but my points still stand.
  • edited July 2011
    Thank you for your responses.

    Actually - I posted this a little bit early yesterday and then I figured out what I really needed to do:

    So: I figured out that to decrypt the image it is not inv(enc)

    Really - the only problem that i am having now is:

    when i separate the magnitude and phase of the image and multiply both pieces with the encryption key, how do i combine the magnitude and phase to get back to the original image?

    would it be point by point multiplcation or how would i go about combining the two pieces to get back?

    because my professor wants us to display the encrypted part of the magnitude and the encrpyted part of the phase and then combine those two parts and then decrypt the image and then run ifft2 on it to get back to the original image.


    i have all the code and it works perfectly when i run the encryption/decryption on only the original image...but i just do not know how to combine the magnitude and phase into 1 image once i separate them..


    if anyone would like....i could email you the code that i have?


    THANK YOU SO VERY MUCH FOR THIS.

    - and we asked our TA....she doesn't know anything about matlab.
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited July 2011
    we're still not clear on exactly what you want to do - a quick flowchart of the encode/decode process would probably help both us and you.
  • edited July 2011
    Here is the flowchat.

    I am having trouble with bringing the magnitude and phase back together...
  • edited July 2011
    i know that we do not have to separte the image into the phase and magnitude...but that is how the instructor wants it done.
  • shwaipshwaip bluffin' with my muffin Icrontian
    edited July 2011
    You can't do the "decrypt the image" step on the recombined magnitude and phase image. You'll need to decrypt the magnitude and phase portions separately.
  • edited July 2011
    Oh! Ok. So once I decrypt them separately....how do i combine them?

    So I should decrypt them separately...then combine and then take the ifft2 and it should be the original, correct?


    The only thing i dont understand is how to combine them...

    would it be:



    DecryptedMagni .* DecryptedPhase = Decrypted Image

    And then do ifft2 on the Decrypted image?



    Thank you very much for your help!!!
  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited July 2011
    It depends on the object you get when you perform the first FFT. You're positive you recover the original magnitude and phase of the results from the first FFT when you do your decryption? If you do, the full complex form is X = abs(Magnitude) * exp(Phase*j) where j is sqrt(-1). Using Euler's formula, that becomes abs(Magnitude) * cos(Phase) + abs(Magnitude) * cos(Phase) * j.

    I found this set of slides interesting: http://www.cse.unr.edu/~bebis/CS474/Lectures/FourierTransform.ppt
  • edited July 2011
    Yes - I tried encrypting just the original Fourier transform without splitting it and then decryped it...and then took the ifft2 and got the original image...so the ecryption and decryption works.

    Would I use the full complex form or the eulers form in matlab when combining the phase and magnitude?

    after combing i would do ifft2(x)

    and then imshow((x), [10 10000]) or soemthing similar to that to get the original image - correct?
  • edited July 2011
    And those were helpful slides!


    Thanks!
Sign In or Register to comment.