CDF issues
- To: mathgroup at smc.vnet.net
- Subject: [mg127627] CDF issues
- From: p.ramsden at imperial.ac.uk
- Date: Wed, 8 Aug 2012 21:35:20 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
Hello everyone. I set up a little toy numerical encryption interface in Mathematica. It uses only InputFields of type Number, so I thought it would be OK as a CDF, but when I use it I get a $Failed in the output pane. It works fine in Mathematica proper, I should stress. Does anybody have any idea what I'm running foul of here? Code is as follows: DynamicModule[{plain = 0, cipher = 0, key1 = 0, key2 = 0, modulus = 100, block = 2, plainBlocks, cipherBlocks, f1 = plus, f2 = plus}, Panel[Grid[{{InputField[Dynamic[plain], Number, FieldSize -> {50, 10}], SpanFromLeft}, {StyleForm["block\n size", FontFamily -> "SansSerif", FontSize -> 18], InputField[Dynamic[block], Number, FieldSize -> {43, 1}]}, {PopupMenu[ Dynamic[f1], {plus -> "Plus", times -> "Times", power -> "Power"}], InputField[Dynamic[key1], Number, FieldSize -> {43, 5}]}, {PopupMenu[ Dynamic[f2], {plus -> "Plus", times -> "Times", power -> "Power"}], InputField[Dynamic[key2], Number, FieldSize -> {43, 5}]}, {StyleForm["mod", FontFamily -> "SansSerif", FontSize -> 18], InputField[Dynamic[modulus], Number, FieldSize -> {43, 5}]}, {Button[ "Encrypt/Decrypt", {plainBlocks = Map[ToExpression, Apply[StringJoin, Reverse[Map[Reverse, Partition[Reverse[Characters[ToString[plain]]], block, block, 1, {}]]], {1}]]; cipherBlocks = Map[f1[key1, modulus], plainBlocks]; cipherBlocks = Map[f2[key2, modulus], cipherBlocks]; cipherBlocks = Map[ToString, cipherBlocks]; cipherBlocks = Map[Characters, cipherBlocks]; cipherBlocks = Map[PadLeft[#, block, "0"] &, cipherBlocks]; cipherBlocks = Apply[StringJoin, cipherBlocks, {1}]; cipher = ToExpression[Apply[StringJoin, cipherBlocks]]}], SpanFromLeft}, {Pane[Dynamic[cipher], Scrollbars -> {False, True}, ImageSize -> {600, 200}], SpanFromLeft}}], "Numerical Encryption"], Initialization -> (plus[key_, mod_][plain_] := Mod[plain + key, mod]; times[key_, mod_][plain_] := Mod[plain*key, mod]; power[key_, mod_][plain_] := PowerMod[plain, key, mod])] Many thanks.