LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview Blowfish encrypt works but decrypting doesn't work

I downloaded the Labview Blowfish VI and have been looking at it. I noticed that when I'm trying to decrypt the text after encrypting it, it doesn't seem to output the original text. 

 

Can someone tell me how I can fix this or where to look at?

0 Kudos
Message 1 of 3
(2,789 Views)

Your code has very fundamental bugs:

 

  • Your output is much longer than the input because you are creating an array of the original length with each iteration and concatenating them all at the output tunnel. Either initialize the final size in a shift register and replace each section OR use the concatenating output tunnel without using "replace array subset" at all.
  • You want to use the same password for encryption and decryption if you want the sentence back.
  • The init belongs before the loop. No need to do it over and over.
  • If you set the VI to "clear indicators when called" (vi properties...execution) you don't need the local variables and stacked sequences. (even without these setting, you don't need them!)
  • removing all underscored at the end is faulty, because the original string might contain some. You need to know the size (look at the example).
  • A lot of your code could be simplified dramatically. I doubt you need anything pink inside the loop.
  • If you would reshape the input array to a correctly sized 2D array, you could use a FOR loop.
  • You need to "replace all" undesscores, so wire that TRUE from the top!
  • You know the number of iterations before the while loops start, thus they should be FOR loops instead.

See how far you get.

0 Kudos
Message 2 of 3
(2,763 Views)

Here's a quick attempt at simplification. Seems to work just fine (but please verify!). This is a very rough draft!

 

(It will not work if the initial string contains \00 before encryption, for example (still better than using underscore as a sentinel value!). I would recommend to prepend the size when encrypting and use that to trim the decrypted result. Seems safer. I would also recommend the usual connector patterns and implement error IO. None of this is implemented.).

0 Kudos
Message 3 of 3
(2,759 Views)