Can AES generate arbitrary ciphertext by choosing plaintext and key? [closed] - aes

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
All my confusion comes from the following example:
key='c086e08ad8ee0ebe7c2320099cfec9eea9a346a108570a4f6494cfe7c2a30ee1'.decode('hex')
IV='78228d4760a3675aa08d47694f88f639'.decode('hex')
pad=lambda S: S+chr(16-len(S)%16)*(16-len(S)%16)
from Crypto.Cipher import AES
cipher=AES.new(key,AES.MODE_CBC,IV)
msg='NO, NOT SECRET!'
cip=cipher.encrypt(pad(msg))
then cip is "IS THIS SECRET??". Therefore, I don’t know if this is purely coincidental or there is some kind of algorithm that can generate the ciphertext I want by properly selecting the key and plaintext.

This is a bit of a puzzle, isn't it? The trick is in first decrypting the IS THIS SECRET?? string using the block cipher. Then the trickster can alter the resulting random "plaintext" by changing the IV. Look up CBC mode to see how.
Finally, the trickster just need to add an encrypted padding block to the ciphertext. OK, since this was probably an assignment that you needed to figure out, please try and create such a weird ciphertext yourself and make it decrypt to a special message of your own.

Related

Using is_numeric to replace a string [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 12 months ago.
Improve this question
In the course of converting some variables from an API, I need to check if the API is returning a string, such as " N/A", and not a number such as "824". This is the code that I'm attempting to use where, if the variable from the API is a number, leave it alone, otherwise, change it to a = (Zero)
$weather["barometer_min"] = (is_numeric($weewxapi[36]) ? number_format($weewxapi[36],0) : "0");
It does not appear to be working, however, it is not throwing any errors. Can anyone guide me in the right direction?
As shown by Syscall, using 3v4l.org, the code works.

Are there copy constructors in Swift structures? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
It's known, that when assigning an instance of structure to another instance, or passing it to a function, Swift essentially copies the instances by value. However I could not find anywhere if we actually have control over this process, like in C++ copy constructors. My question is whether Swift has analogue to C++ copy constructors and if not, are there anything in the language what helps to take control over passing-by-value process in Swift?
Copy constructors are implicit in Swift, and can't be user-customized.
They always copy all fields of a struct. For fields that are references to object, copying is defined as the increment of reference count (a retain).

how to modify rules in perlcritic [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Hie ,
Perl critic (Source Code Analyser).
I am new to this . Although I have studied the documentation and know how to run it (That's not enough!).
I want to modify the rules (i.e include,exclude or add my own rules to it).
I know .perlcriticrc file can do that.
But I don't know how to do it.
Thank you
According to the doco for Perl::Critic, you can add a "policy" with the add_policy( -policy => $policy_name, -params => \%param_hash ) method:
-policy is the name of a Perl::Critic::Policy subclass module. The 'Perl::Critic::Policy' portion of the name can be omitted for brevity. This argument is required.
Then, when you look at the linked documentation for the subclass module (emphasis mine);
To work with the Perl::Critic engine, your implementation must behave as described below. For a detailed explanation on how to make new Policy modules, please see the Perl::Critic::DEVELOPER document included in this distribution.
... we see there's a whole document covering exactly what you want to do.
What part of that document are you having trouble with?

Is there a Coffeescript equivalent for Dart [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
The main aspect of CoffeeScript I'd like to see available also for Dart in form of a different, Dart-based language would be less verbosity, less brackets, less Java-style.
Does such solution exist ?
No.
If you don't want to have your field static you can omit the static keyword.
If you don't want to have your field final you can write var or a concrete type instead of the final keyword.
And if you don't want a loop you can omit for, while, forEach, ...

Is the best Scala convention to invoke collection.size or collection.length [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I understand these two methods are identical (one is defined in terms of the other) according to this previous question:
Scala Buffer: Size or Length?
But is there a reigning best practice or recommended convention? I can think of three options:
(1) Always use size
(2) Always use length
(3) Use size for all collections exception Array
I'm leaning towards (1) or (3). The rationale behind (3) is that these methods are inherited from Java. And in Java you'd be invoking collection.size() and array.length. The argument for (1) is that it builds on and simplifies (3). The argument for (2) I'm not really sure about.
They are the same. It makes no difference. Use whatever you want.