Monthly Archives: January 2006

Something about .Net RSA

Recently I have a project that needs encryption support. The requirement is to encrypt with the private key of RSA algorithm and decrypt with the public key. I went the algorithm again and thought it is doable, so I began to write a prototype with c#. But I got an ‘invalid key’ error when decrpting the data encrypted from the private key.
After some search,I learnt that it is by design of .Net framework. It disables decryping with public key for security reason.
Finally I came to implement the RSA algorithm myself to achieve what I want to do.

JPEG to html

DSCN1414.JPGSome times I saw some visitors to our web site by search for “JPG to html”.

We don’t have a jpg to html product. What we have is html to image solution including end-user product Html To Image and development tool Html Snapshot. Their function is to convert html to image such as JPG, PNG, TIFF and GIF.

Come back to the topic “JPG to html”, frankly speaking, I don’t quite understand what it exactly means. JPG is a graphic format while html is a markup language in text format. The procedure of “convert html to jpg” implemented by our products is not reversible. This means, you can not generate the same html text file from the image.

Actually it is a quite difficult problem for computer to recognize the text or image on a big graphics. OCR or computer vision is trying to achieve this goal but is not successful yet.

Or does it mean to put an image into html page? If so, it is another problem: html page authoring. By making use of a WYSIWYG html editor, it is easy to put jpg to html in a few mouse clicks.

Don’t buy wrong product.

We have a long list of order page for our products. Each product occupies a row of a table.

We are currently using the services of two online shareware trade company: Qwerks and Regsoft. Both are well-known and among the best.

Before clicking the links going to qwerks or regsoft, please make sure you are in the correct row for the product. :)

When you goes to the order page on qwerks or regsoft. You will also notice the product name on top of the order page.

Please do have a look and double check.

Some customers do have made such mistakes. If you take a look before going ahead, you can save both your and our time.

Thanks 

A stress test example

 

When developing our development tools product, we have consider the stress DSCN1338.JPGtesting scenarios. Since our product might be used in server scenarios which means it should be stable, reliable.

 

We try hard to make sure the function still works after calling thousands of times. So we design a bunch of stress test cases for our products.

Here is a simple testing case for our PDF split and merge product. It is an ActiveX component that supports easy pdf split and merge.  

Private Sub Command1_Click()
For I = 1 To 100  ‘Change this number if you want more
DoMerge
Next I

End Sub

Private Sub DoMerge()
Dim pdf
Set pdf = CreateObject(“PDFSplitMerge.PDFSplitMerge.1″)

pdf.Split “..1.pdf”, “1;1;1″, “..sp1-%d.pdf”
pdf.Split “..1.pdf”, “1;2;3;4;1-2,3-4;1″, “..sp%d.pdf”

pdf.Merge “..sp0.pdf|..sp1.pdf”, “..m1.pdf”
pdf.Merge “..1.pdf?1-2|..sp1.pdf”, “..m2.pdf”
pdf.Merge “..1.pdf?1-2|..sp1.pdf?2″, “..m3.pdf”

Set pdf = Nothing
End Sub

How to do manual registration of Html To Image.

Some people experienced strange problem when registering html to image from the UI. We usually solve it by manually registering. Here is the process:

1. Make sure you are running latest build of Html To Image. It can be always downloaded here.

2. Make sure you have closed Html To Image program. i.e., it is not running.

3. Open the folder C:Program FilesHtml To Image. This is the default installation folder of html to image. Double click to open the file strings.ini in notepad.

Now edit the file, find the following lines. If they are not there, add them directly.

[Common]
Name=User Name
Code=ABCXXXX-XXXX-XXXX-XXXX

Replace “User Name” with your own name when purchasing. Replace the “ABCXXXX-XXXX-XXXX-XXXX”  with the code you get in the order email

4.  restart Html To Image, you should be registered then.

Still not?  let me know :)

 

DSCN1323.JPG

 

 

Using Active TTS in C#

Active TTS is a standard COM component that is supported by .Net framework.

 

Here is a step by step example of using Active TTS in a C# winform project with VS2003.

1. Create a C# winform project by using the IDE wizard.

2. Add reference to TTSObj.dll by clicking main menu item, Project->Add Reference, pop up the dialog, choose “COM” tab, click the “browse” button to pick up the TTSobj.dll (You can find it in the default Active TTS installation folder which is C:Program FilesActive TTS).  

activetts.jpg

  Click OK, you will find TTSObj name space in your solution explorer.  

solutiontts.jpg

  3. Now you can use Active TTS object like a normal C# class in your code.  For a working demo, please look into the DemoCSharp in the trial package. 

You can see how easy it is to incorporate the text to mp3 function in your application.

            ttsObj = new CTextToSpeechClass();

            comboBox1.Items.Clear();
            for(int i = 0; i < ttsObj.VoiceCount; i++)
            {
                comboBox1.Items.Add(ttsObj.GetVoiceName(i));
            }
            comboBox1.SelectedIndex = 0;
            ttsObj.VoiceIdx = comboBox1.SelectedIndex;

            ttsObj.OnTTSEnd += new _ITextToSpeechEvents_OnTTSEndEventHandler(ttsObj_OnTTSEnd);
            ttsObj.OnTTSStart += new _ITextToSpeechEvents_OnTTSStartEventHandler(ttsObj_OnTTSStart);
            ttsObj.OnTTSProgress += new _ITextToSpeechEvents_OnTTSProgressEventHandler(ttsObj_OnTTSProgress);
            ttsObj.OnTTSWord += new _ITextToSpeechEvents_OnTTSWordEventHandler(ttsObj_OnTTSWord);

 

 

TTS on Windows

 

DSCN1300.JPG

  

Windows currently has two speech APIs. One is SAPI4 on Windows 2000. The other is SAPI5 since Windows XP.

However, it is possible to use SAPI5 on windows 2000 or even windows 9x. You can install Speech SDK 5.1 which has included SAPI and some free TTS voices as well as speech recognition engines.

Our TTS products, Active TTS/Speak Aloud support both SAPI4 and SAPI5 voices. It also means they depend on SAPI4 or SAPI5. So the machines should have SAPI4/SAPI5 and some TTS voices installed beforehand.

Make an audio recorder with voice activity detection

I was often asked about a question about Active Audio Record component: Can I detect the input audio level without start recording?

The answer is NO. The reason is that if the recording is not started, sound card doesn’t sample any input signal then no audio level can be returned.

So does it mean you have to record many non-sense silence data into your audio files? Surely not. :)

We have considered the scenerio from very beginning design of Active Audio Record. Silence detection (so called voice activity detection) is an important feature in the component.  You can easily make a typical audio recorder with voice activity detection by integrating Active Audio Record. The detailed steps are:

 

1 . Create an Active Audio Record object, set the appropriate device index and input source device line. (microphone or wavemix etc)

2. call SetDetectSilence(TRUE) to enable silence detection. Don’t forget to SetSilenceLevel as well. Silence definition varies with the environment you are in or the audio signal you cares about.

3. Set a timer to monitor the recording status 

4. Now start recording by calling StartRecord. Since silence detection is enabled, the initial silence audio data will not be saved into audio file.

5. In the timer callback function, you can call GetRecordTime to determine how many audio data have been saved and call GetSilenceTime to get how many silence have been detected currently. Note, this silence length is not accumulated. If some non-silence data come in, the silence length will be reset to zero. So you can use this silence length to determine whether or not stop recording or split audio tracks by silence.

 

DSCN1290.JPG

 

Convert html to image in IIS

This article will discuss how to use html snapshot to convert html to image (JPG, TIFF, GIF, PNG and BMP) under IIS (with ASP or ASP.net)

First, we will discuss IIS 5.0 on Windows XP.  

There are two accouts in IIS 5.0. IUSR_MACHINENAME, IWAM_MACHINENAME.

For the default setting, IUSR_MACHINENAME account is used to access files (reading or writing).

IWAM_MACHINENAME is used to run out-of-process ActiveX object such as Html Snapshot.

For normal html page without ActiveX in it,  we just need to give the IUSR_MACHINENAME write access to the folder  for saving images.

But html page may contain ActiveX such as Macromedia flash movies. The flash ActiveX control needs much privilege to run. I think It needs to access sound card resources etc.

If you don’t want flash to be captured, so it is simple to disable it with the call:

 snap.EnableActiveX 0

But if you want flash, then you need to give enough privilege.

You can do following things:

1. Run DCOMCNFG, click to expand the Component Services, Computers, My Computer, and COM+ Applications nodes. Right-click the IIS Out-of-Process Pooled Applications object, and then click Properties.
On the Identity tab, Set the account to your admin account or current interactive logon user instead of the default one (IWAM_MACHINENAME).

Note, after the account changes, you need to restart IIS (or kill the dllhost.exe running under IWAM_MACHINENAME with taskmgr).
2. Call SetLogOnUser(“admin”, “.”, “password”) before calling SnapURL. Then SnapUrl will impersonate with the logon information when converting html to image.
 

If you use Windows 2003, it is a totally different story since Windows 2003 uses IIS 6.0.

To convert html pages with flash movie to image on Win2003 server, you can do following:

1.  In IIS admin UI, Set the Application Pool property, right click the DefaultAppPool, click property->Identity, Set the account of application pool to Local Service or Local System. (Note, you must set the account to Local System if you want to convert html page which contains ActiveX like Flash movies)

Also, remove “internet explorer enhanced security” in the control panel. It may block the action to convert a URL to image.

2. Call SetLogOnUser(“admin”, “.”, “password”) before calling SnapURL. Then SnapUrl will impersonate with the logon information when converting html to image.

See a snapshot of www.macromedia.com below.

 

macromedia