Pushdown Automaton to accept all strings such that no prefix has more 1’s than 0’s

Design a Pushdown Automata, accepting either by final state or by empty stack to accept the set of all strings of 0’s and 1’s such that no prefix has more 1’s than 0’s

This is a homework question, but not graded.

I’m not looking for the answer, right now I’m just trying to understand the question. I don’t understand what sort of words would be accepted and what would be rejected. For example, I can’t understand whether the following word would be accepted:

011011 ; where 01 is prefix and 1011 is suffix
011011 ; where 011 is prefix and 011 is suffix
011011 ; where 0110 is prefix and 11 is suffix

I guess my question is this: Given a word, how do I know which part is the prefix? I don’t think I can proceed with the question unless this part is clear.

Please try to give an explanation without the actual PDA answer, I’d like to try it myself first.

Thanks!

AngularJS 1.6.6 no eval / strings XSS

I’m testing web-app where i can not use strings or eval word(blocked by waf), they are running on AngularJS 1.6.6

I have seen this payload which fits my needs for version 1.4.0 but not does not work for 1.6.6

{{toString().constructor.prototype.charAt=[].join; [1,2]|orderBy:toString().constructor.fromCharCode(120,61,97,108,101,114,116,40,49,41)}}

I have very little experience with AngularJS, so my question is if similar payload is possible to construct for version 1.6.6 and if anyone is kind enough to guide me how to construct one.

Obfuscating “sensetive” strings in mobile client

We have a client that runs some native (C++) code on both Android and iOS, to mitigate MITM attacks we use certificate pinning.

This means that the binary includes some strings (const char * const bla = "XXXXXXXXXX") that identify the allowed certs to enable HPKP.

Some are worried that nefarious users will easily identify those strings because they look like SHA256 and are passed to relevant functions, replace them and analyze the traffic.

  • Would it make it objectively harder if we obfuscated those strings in compile-time and then de-obfuscate them at run-time?
  • Would it make it worse because now instead of being in R/O memory (Speculation… I know… it’s not required by the standard but it makes a lot of sense) we just read it at run-time from some regular object?

Should error codes in JSON be integers or strings?

I’m designing a backend webservice, and when an error occurs I’m returning it as a JSON to the frontend. This JSON contains an error code, which the frontend maps to an localized string and shows that to the user.

Should my error codes be strings or integers?

{   "code": 9900,   "message": "Invalid ID" } 

OR

{   "code": "9900",   "message": "Invalid ID" } 

I’m thinking integers myself, but I’m just wondering if maybe returning fixed length error codes would be more correct, like if I atm have error codes like 9900, 9901, and in the future I wanna send the code 12, would it be correct to send them as "9900", "9901", and "0012", vs 9900, 9901, and 12.

Why does the JSON specification disallow single quoted strings? [on hold]

I understand that only double quoted strings are allowed in JSON but why would this limitation be introduced from a software engineering perspective? In JavaScript you can use single quotes when defining object literals, so why would the writers of the JSON specification deviate from JavaScript language semantics in this way?

Could this have been done purely to make the specification simpler?

Could other issues related to performance or security have come into play when making the choice to allow only one type of quotes for string?

Also is there any background to why double quoted strings were only allowed even though single quotes also happen to be easier to type as they are accessible without having to use the shift modifier on a keyboard? For example, was this done because single quotes are more common in text strings (hence there would be more instances of having to escape single quotes if only single quotes were allowed for strings versus the opposite scenario)? Or was this done primarily due to the popularity of double quotes relative to single quotes as string delimiters.

IS good idea to use constants instead of raw literal strings and when is a bad one? [duplicate]

This question already has an answer here:

  • Usage of magic strings/numbers [closed] 4 answers

Usually when I code in PHP I try to avoid using literal strings in cases such as:

define('IMAGE_DOWNLOAD_PATH','./data/images/'); define('IMAGE_FILENAME_PREFIX','myapp_'); $  url="http://exaple.com/image.png"  function genFilenamesForDownload(string $  url): string {     $  extention = pathinfo($  url, PATHINFO_EXTENSION);      return IMAGE_DOWNLOAD_PATH.IMAGE_FILENAME_PREFIX.hash('sha512',$  url).".$  {extention}"; }  

My rationale behind this is that using constants I make my code more self-documenting and I do not spend time to guess what each literal value is.

But on my experience some developers that I collaborate with find this approach more confusing whilst I find this approach more easy-to-understand especially for new employees or collaborators to the project.

So I wondered which approach is better, to directly use literals or to define my literals as constants? Also is this approach good for all cases?

How to search strings in certain files using absolute path by grep

I want to search for a certain string in several files using absolute path, say that I want to find all occurrences of inheritDoc in sevral java files, I have tried the following command:

grep -inr \ --include /opt/li/projects/universign-copy-2/universign/universign-server/src/com/cryptolog/universign/server/HealthCheckHandler.java \ --include /opt/li/projects/universign-copy-2/universign/universign-admin-www/src/com/cryptolog/universign/admin/actions/HealthCheckAction.java \ --include /opt/li/projects/universign-copy-2/universign/universign-www/src/com/cryptolog/universign/www/action/HealthCheckAction.java \ --include /opt/li/projects/universign-copy-2/universign/universign-core/src/com/cryptolog/universign/core/HealthCheckConfiguration.java \ --include /opt/li/projects/universign-copy-2/universign/universign-core/src/com/cryptolog/universign/core/HealthCheckResult.java \ --include /opt/li/projects/universign-copy-2/universign/universign-core/src/com/cryptolog/universign/core/utils/HealthCheckUtils.java \ --include /opt/li/projects/universign-copy-2/universign/universign-core/src/com/cryptolog/universign/core/utils/HttpUtils.java \ inheritDoc 

But that does not work. How could I possibly do this?

Is throwing malicious strings in json_encode a good way to evade Stored XSS?

I’m aware that filtering strings doesn’t go this way, but when encoding xss payloads into json format in php and storing that information temporary in classes, the result in the browser, it will show all the strings that are before the javascript content, the payload in the middle won’t execute since i use json_encode for all the strings and all what is after the javascript content is not displayed in the browser. but can i use this in real world applications?


Here is the generated content after the submit

enter image description here

I use a picture to read with more comfortability

Retorno falso ao comparar duas strings identicas em python

Estou tentando comparar duas strings, uma vem do banco de dados como um array, a outra é escrita a mão:

  string = str(profile[1]) #Carlos Gimenes   print(string == str('Carlos Gimenes'))   #Retorna false 

Já tentei de várias formas e não consigo fazer isso retornar true, ao exibir o tipo da variável é retornado que ambas são <class 'str'>, ainda sim o valor retornado continua como false.

link do projeto:https://github.com/CaduGimenes/recognizer

What does “if not” have to do with strings?

I would ask this on Stack Overflow but my account can not ask questions at the moment so I will ask this question here: I have been reading about how to figure out if a string is empty, and I saw if not being used. I tested this out and it did what I needed, but I was wondering how it worked. So i researched and discovered not is used when a condition is supposed to equal false and is used withif making an if not. But what does this have to do with wherever a string is empty or not?

My code:

#!/usr/bin/python Random = "" if not Random:     print (' Hello ') else:    print (' Goodbye ')