## Write a python or C program to guessing the Key

Key generation program in C:

#include <stdio.h>   #include <stdlib.h>   #include <time.h> #define KEYSIZE 16 void main() { int i; char key[KEYSIZE]; printf("%lld\n", (long long) time(NULL)); srand (time(NULL)); for (i = 0; i< KEYSIZE; i++){ key[i] = rand()%256; printf("%.2x", (unsigned char)key[i]); } printf("\n"); } 

Scenario:

On April 17, 2018, Alice finished her tax return, and she saved the return (a PDF file) on her disk. To protect the file, she encrypted the PDF file using a key generated from the program described above.She wrote down the key in a notebook, which is securely stored in a safe. A few month later, Bob broke into her computer and gets a copy of the encrypted tax return. Since Alice is CEO of a big company, this file is very valuable.

Bob cannot get the encryption key, but by looking around Alice’s computer, he saw the key-generation program, and suspected that Alice’s encryption key may be generated by the program. He also noticed the timestamp of the encrypted file, which is “2018-04-17 23:08:49”. He guessed that the key may be generated within a two-hour window 1 before the file was created.

Since the file is a PDF file, which has a header. The beginning part of the header is always the version number. Around the time when the file was created, PDF-1.5 was the most common version, i.e., the header starts with %PDF-1.5, which is 8 bytes of data. The next 8 bytes of the data are quite easy to predict as well. Therefore, Bob easily got the first 16 bytes of the plaintext. Based on the meta data of the encrypted file,he knows that the file is encrypted using aes-128-cbc. Since AES is a 128-bit cipher, the 16-byte plaintext consists of one block of plaintext, so Bob knows a block of plaintext and its matching ciphertext. Moreover, Bob also knows the Initial Vector (IV) from the encrypted file (IV is never encrypted). Here is what Bob knows:

• Plaintext: 255044462d312e350a25d0d4c5d80a34
• Ciphertext: d06bf9d0dab8e8ef880660d2af65aa82
• IV: 09080706050403020100A2B2C2D2E2F2

Your job is to help Bob find out Alice’s encryption key, so you can decrypt the entire document. You should write a program to try all the possible keys. If the key was generated correctly, this task will not be possible. However, since Alice used time() to seed her random number generator, you should be able to find out her key easily.

## Can you hide your OS from programs? Can you trick a program into thinking you are on a different OS?

I’ve been surfing through the internet for the past hour now, and I haven’t seen any answer to my question. I couldn’t even find my question on the web. Is there a way or program to make another program think I am using a different system? For example, let’s say currently I am on Windows 7 32-bit and I want the program to detect Windows 10 64-bit or perhaps Windows XP. Can I do something similar with hardware? Can I tell a program that I’m running on a pc from the early 2003 even tho it’s from last year (2019)?

## What must be in a “program” to make it “a program”?

I understand it is possible to reduce a “program”, in a maximal reduction, to these features:

• Internal implementation: Everything from start to end, including possible functions and possible sub functions
• External interface: A parameter set with which arguments might correspond in call → if any

Internal implementation includes:

• Data structures: Primitive data types and possibly also functions or modules (depends what term one prefers)
• algorithms: outside or inside a function/algorithm → if any
• Database interfaces → if any

I understand that external interface (very often represented by parenthesis) can be part of internal implementation (very often represented by brackets) and if yes or know depends from language architecture.

This is what I came up with from my synthetic prior research but I might be wrong.

What must be in a “program” to make it “a program”?

## Program Transfer function and plot

I need to program a transfer function T(s) = 1/(s^2+Bs+1) and simulate the response of a unit step input of the Force for each value of B which i used in my range my B values are 4,2,1.8,1.4…….

tfm = TransferFunctionModel[(1)/(s^2 + Bs + 1), s]; tfm[I Range[4,2,1.8,1.4,1,0.6,0.2,0.02]] Plot[Abs[tfm[I f]], {f, 0, 5}] 

What am I doing wrong?

## Is this program O(n^2logn) or O(nlog^2(n))?

I was wondering whether this program (I’m using a C syntax, hope it’s not an issue) is to be considered $$O(n^2 \log(n))$$ or $$O(n\log^2(n))$$ or something else entirely.

for(int i=0;i<n;i++)     for(int j=i; j>0; j/=2)         for(int k=j; k>0; k--)             printf("Hello, World!\n"); 

I mean, the innermost loop is for sure $$O(n)$$ but maybe it could have a tighter asymptotic upper bound? It executes a number of times that is dependent on a logarithmically decreasing value (j), so I’m not really sure how would I have to think about such a scenario.

## Does there exist a program that can search not only the names of the links inside your Google sheet but also the contents of those links?

Background: I have a Google Sheet that has some links in it. Of course, links don’t always have the contents of what you are looking for the URL, so trying to search for it later is hard.

Question: Is it possible to peek into the contents of the website to find a keyword?

Ex: Let’s say I have google.com cs.stackexchange.com stackexchange.com/bunnyrabbits (made this one up) And the last link contains words like “snake” and “turtle”. If I CTRL+F “snake”, there will be no results. Is there a way to look into the link without having to check each link one by one?

(Note that the tag on the bottom is because I don’t have enough reputation to put general, sorry)

## In what sense the computer program (Turing machine) can be considered as the complex system and its IIT Phi can be measured and improved?

I am reading https://global.oup.com/academic/product/a-world-beyond-physics-9780190871338?cc=us&lang=en& about one approach of complex systems’ theory for the emergence of the life. It is about the autocatalytic soup of molecules from which the life can emerge. Of course, one is thinking further – every computer program, every Turing machine is more ore less autocatalytic soup of interacting software components from which the consciousness, mind and Artificial General Intelligence (https://content.sciendo.com/view/journals/jagi/jagi-overview.xml) can emerge.

Of course – ther program (Turing machine) should be of sufficient complexity for such consciousness to emerge – and such complexity/level of consciousness can be measured by Phi measure of https://en.wikipedia.org/wiki/Integrated_information_theory .

My question is – how the theory of complex systems is applied to the software programs (including logic programs, sets of first order formulas, knowledge bases, functional programs, lambda terms), e.g. to derive the directions (modular organization, wealth of functionality, et.c) for evolving the programs into the programs with higher level of Phi, whith higer level of autonomy and consciousness? I presume, that consciousness is the driving force for the program to exhibit commonsense knowledge, for the capability to make generalizations and transfer skills among tasks (all those are very hot topics and deep learning community without almost any theory behind them). All these issues are the grails of current computer science and that is why my question is very applied in nature.

Currently computer programs and algorithms are developed in trial-and-error process. The development of software systems that are called cognitive architectures (http://bicasociety.org/cogarch/architectures.php) or that are called cognitive systems (http://www.cogsys.org/journal) is prominent features of such efforts. But maybe the theory of complex systems can be applied to such programs to determine why such programs exhibit or do not exhibit the capabilities of consciousness (as determined by IIT or any other computational theory of consciousness or mind – there are some others, academically sound) and what can be do on such programs to evolve them into capable systems with higher Phi. We have tried to design and program features but no cognitive architecture has achieved sufficient level of AGI. We can try still more harder. But maybe the theory of complex systems can provide some guidance to estimate the weak points and to provide some direction?

Just some reference for applying the theory of complex systems to the programs in the widest sense?

## Program language in which every every string generated by its grammar is a nicely running program?

Was wondering if there is a programming language out there such that every string generated by its grammar (the grammar is given as well) is a program that does not crash.

This is so that the set of all possible programs (that don’t crash) on the machine, in that language, is generated by the grammar and the grammar generates exactly those programs.

## Can a computable program have an infinite output?

Can a computable program produce an infinite output from its (presumably finite) input?

*I wouldn’t think so for similar argument as to why it can’t compute over an infinite input.

A follow on (basically the same?) question: Are there non-halting programs that are computable?

Thanks!

## Writing a linear program to model balanced bin packing

Say we want to write a (MI)LP to model the following problem:

Find a parking plan for a set of cars $$K=\{1, …, k\}$$ with lengths $$\lambda_i$$. Parking is organised in lanes $$P=\{1, …, p\}$$. The length of a lane is the sum of the cars parking there and may not exceed a specified constant $$L$$. The goal is to balance the lengths of the parking lanes as well as possible. More specifically, we want to minimise the difference of the length of a longest and shortest line.

To me, this seems quite akin to some variant of the Bin Packing problem. Usually, however, we want the number used bins to be minimised.

Here, I am quite confused on how I could come up with an objective function that expresses the balance between the lanes/bins. My main problem is that — as far as I understood it — the objective function has to be linear. Thus, I couldn’t use operations like max, min, absolute value etc.

Can someone help me out here with a hint?