How to generate random text?

Hi,

I want to generate some random text from a given a text…want to get the text of same size and format as the given text.

Note: You may not need this …but reason I’m doing this is I want to mask some sensitive data in my page before sending to someone…want to keep mask text of same size.

You should e able to get close enough with something like this: http://www.perbang.dk/orcapia.cms?aid=100 (There are any number of generators available on-line.)

I dont see any option there to generate text from a given text preserving size.

Am I missing something ?

Sorry - perhaps I’ve misunderstood. I thought you were looking to generate text to fill the same amount of space, so you could use the word count to get a close approximation and just adjust a little as necessary.

Where is the text coming from?

how to word count ? need to use separate tools ? or I can do that on-line ?

As @Gandalf asked, what is the source of the text? MS Word or similar will give you a word count, as will most HTML editors, AFAIK.

source = database column values

I have Bracket…Is it possible to see word count there ? whats the way ?

Try this. https://wordcounter.net/

1 Like

Just as an afterthought, I tried downloading the wordcounter site as a complete webpage (as described yesterday). On opening the page up locally, its functionality still works fine for what you need (I tried it in IE11 and Chrome). So if you’re at all concerned about using an open internet site due to the sensitivity of your content, then try it that way.

In that case could you use PHP to replace every alphabetic character with another random alphabetic character?

Does the text need to fill exactly the same space? Different characters take up different amounts of space in most fonts and so switching characters randomly can affect the length of the text even though it contains the same number of characters.

For example compare the following two 10 character strings

iiiiiiiiii
MMMMMMMMMM

it the two strings need to be as close as possible to the same length then perhaps you could convert the entire text into an array of single characters, shuffle it, and then convert the array back to text. The resultant length will possibly be slightly different from the original depending on where the spaces end up but it will likely be closer in length to the original than if you also substitute different width characters.

For example:
The rain in Spain falls mainly on the plain.
could become
r .hl yT ian apeli mei paiaotnnsnlnahlSf n i
providing text of exactly the same length

5 Likes

Yes…you got me…I would love that . Is there any easy workaround which does that exactly? how to achieve that ?

As I mentioned previously - explode() the text into an array, shuffle() the array, and implode() the array beck to text.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.