How do I use the print function to output a numeric variable with a fixed amount of leading zeroes

I need to create an output from a T-SQL query that picks a numeric variable and uses the print function to output with leading zeroes if it is less than three characters long when converted to string.  For example if the variable is 12 the output should
be 012 and if the variable is 3 the output should be 003.
Presently the syntax I am using is PRINT STR(@CLUSTER,3) .  But if @CLUSTER which is numeric is less than three characters I get spaces in front.
Please help!

>> I need to create an output from a T-SQL query .. <<
NO! NO! In RDBMS, we have a presentation layer that handles displays. We do not ever do it in the database. This is fundamental. But more than that, the purpose of PRINT is for debugging in T-SQL and never for output.
You are still writing 1960's COBOL or BASIC, but you want to to it in SQL.  You probably picked the wrong data type (a numeric that should be a string) and are trying to repair your design error.  
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • How can I use the print module to print different size images on one large "canvas"?

    How can I use the print module to print different size images on one large "canvas"? An example would be in Photoshop, go to file>new, and create the size paper I want, and move images of different sizes onto it.
    I was thinking the print module would do this automatically for me.

    You can't, at present. It's been a requested feature, so we'll see if it shows up in a future version, but it's not there at present.

  • Do i need to upgrade from OS X 10.5.8 to a new version to be allowed to be able to use the print function of Iphoto 08 ?

    Do i need to upgrade from OS X 10.5.8 to a new version to be allowed to be able to use the print function of Iphoto 08 ?

    You can upgrade to iPhoto '09 with a purchaed iLife '09 DVD - or yu can upgrade your OS and purchase an iLife '11 DVD
    Eitehr shuld be aviailable from amazon, eBay an dother places
    LN

  • I can hear the caller, but they cannot hear me when I use the speaker function on my iPhone4.  Are there any fixes?

    I can hear the caller, but they cannot hear me when I use the speaker function on my iPhone4.  Are there any fixes?

    Basic troubleshooting steps outlined in the user guide are restart, reset, restore from backup, restore as new device.  Try each of these steps until your problem is solved. If these steps fail to solve your issue, then you'll need to bring your phone into Apple (or an authorized service provider in your area) for evaluation.

  • How can I use the scan function of Kyocera Printer FS-1020 MFP on MAC? OS X 10.6.8?

    Print function is normal, but I don't know how to use the SCAN function. Is there any specific setting to do to activate the scanner function?

    Try Applications/Image Capture to see if you can scan.

  • How can I use the "EvalScript()" function? I am trying to send text to a Director app from the web browser, but the console in the browser just responds "Uncaught ReferenceError: evalScript is not defined ".

    I am trying to control a Shockwave app form another machine, using "Pusher" service (websockets), and everything is ok so far; but when I try to send the shockwave app the text recieved from another machine, using the "EvalScript()" function (as documented), I only get the message "Uncaught ReferenceError: evalScript is not defined" in the browser's console. What am I doing wrong?
    'm using the following script in the webpage where the shockwave object is located:
      <script type="text/javascript">
        // Enable pusher logging - don't include this in production
        Pusher.log = function(message) {
          if (window.console && window.console.log) {
            window.console.log(message);
        var pusher = new Pusher('abc963cf3e6g678879e');
        var channel = pusher.subscribe('Galileo_channel');
        channel.bind('Galileo_event', function(data) {
          evalScript(data.message);
      alert(data.message);
      </script>
    The "alert" is working fine, but I can't get JavaScript to recognize the EvalScript (I even tried calling the shockwave object, ie: "extev01.evalScript()", since the object's ID is extev01, but it doesn't work, either).
    Help!

    Thanks Sean.
    I tried your suggestion first, using getNetText to poll the server and read a text file. The drawbak is that I had to poll the server constantly, since I could not know in advance when the text file was going to change (and it's not practical to stump the server and connection).
    I've kept trying the EvalScript, asigning the Shockwave object to a variable first, then calling the EvalScript() in the object, but it doesn't work, either. I think I will simply use JavaScript and forget about shockwave altogether, since everything is working fine up to that point (although it would be nice to be able to use Lingo for the rest of the app).

  • I cannot print any kind of document using the File Print command on the tool bar of any application, but I can print using the printer icon. OS X 6.8 with HP Photosmart printer. Any thoughts?

    When trying to print any kind of document on my wife's Mac Pro, the File>Print Command will not work. She just downloaded an update to Microsoft Office and the problem began after that, but it also applies to other non-Microsoft Applications. However, the print function does work when you use the printer icon in any of the applications.  She has OS X 6.8 and an HP Photosmart printer. Thank you for any thoughts.

    Did your wife also apply the Feb. 2 Security Update 2012-01 v. 1.0 from Apple? That update contains a bug which disables printing and some other functions in applications that were originally written for the PowerPC processor and which require Rosetta to run on Intel Macs. Fortunately, yesterday Apple released v. 1.1 of the update, which resolves the problem. Run Software Update again to install the revised update.

  • How to read data after using the PRINT function in visual basic

    I know the benchlink can capture the spectrum analyzer screen for me, but I want to integrate it into my application. I use NI spy to detect the communications from the benchlink and put it into my application. After sending the "PRINT 0" command, my "ilrd SpectrumAnalyzer, temp, 500" command doesn't work, giving me EARG error. Does anyone knows if it is because I can not define the temp to be string or some other problem?
    b.t.w, the communications I get from NI Spy actually read some unknown characters from the instrument, what kind of data it is? Any idea how to use it?
    thanks.

    Hello elm,
    This is completely dependent on your instrument; if you are getting the data then you are halfway there. Look in your instrument's programmer's reference manual to see if they mention how the picture is encoded in bytes. There are so many different ways to encode a picture in binary that speculating and guessing would probably never yield the true result. If there is no mention in the manual, contact the instrument manufacturer.
    Sorry I could not be of more help.
    Scott B.
    Applications Engineer
    National Instruments

  • How do I use the WriteToMemoryXX functions in a CIN?

    I'm getting a linker error "unresolved external reference _WriteToMemory16" when I compile the C code that contains the calls to the WriteToMemory16 function. I've installed the accesshw files and am including the accesshw.h file in my C-code CIN. It would seem that I need to compile-in the code for the WriteToMemory function, which I assume resides in accesshw.c.
    My application calls for some direct hardware i/o that falls in the "too messy to do in a block diagram" catagory. I'm using Labview 5.1.1 and talking to a Keithley Metrabyte PIO-96 card.
    Thanks very much for any assistance.

    Ben,
    Thank you for the response. I looked at the examples you mentioned, but unfortunately I'm still unsure what to do. As mentioned, I downloaded the accesshw.zip file and installed the files in order for me to use InPort and OutPort VIs in my program on an NT box, which I'm doing and is working fine. Also, I downloaded the example, "PCI-DIO using AccessHW_DLL.c". This C file contains calls just like the ones I want to use (calls to WriteToMemoryXX) in my CIN C code to basically do the same operations as are done by the InPort and OutPort VIs. Is there a makefile available for that C file? Maybe if I knew how to build that file into a CIN, it would be the same process for me to build my file into a CIN. There is an include file in the "PCI-DIO using AccessH
    W_DLL.c" file that I don't have (ansi_c.h), but I don't get a compiler error when not including this file in my C file so
    I assume I don't need it. I've got the accesshw.dll file in the same directory as my .c file, as instructed to do on the accesshw.zip download page.
    I'm developing the CIN using MSVC++ 4.0 if that helps.
    Thanks very much,
    Jeff

  • How do I use the TRIM function in my Query?

    I have a field that has called AP.service_user_defined_1 that houses a Code the code is like Alpha Num ie "AA01" then it has about 30 to 40 whites spaces and then the description of what the code means. I need to have the description to show in my report I don't necessarily need the code but I do need the description I tried putting the TRIM Function in as below and it will not work what do I need to do to correct this?? I need help ASAP this is due today! Thanks for any help!
    SELECT DISTINCT
              A1.AUTH_NUMBER,
    PM.LAST_NAME,
              A1.AUTH_TYPE,
              A1.PLACE_OF_SERVICE,
              A1.OVERALL_STATUS,
              A1.CLOSED_REASON,
              A1.DENIED_REASON,
    Case
    when A1.DENIED_REASON in ('HS001','HS002') then 'MED NECESS'
    when A1.DENIED_REASON in ('HS004','HS005','HS006','HS007','HS008','HS013','HS014','HS016','HS017','HS019','HS020') then 'Admin Denial'
    when A1.DENIED_REASON is NUll and ap.advisor_decision = 'AAPPR' then 'Approved'
    else 'Unknown'
    end DENIED,
    A1.admit_primary_date,
    A1.service_admit_type AS "IP ADMIT TYPE",
    A1.service_user_defined_1 AS "OP Serv Type",
    Trim (leading ('AA01                 ',)from dual,
    ap.contact_date,
    AP.decision_date,
    AP.ADVISOR_DECISION,
    PM.PROVIDER_ID,
         A1.INSERT_DATETIME,
    TO_CHAR (A1.insert_datetime,'MONTH-YY')AS "Month",
    A1.admit_primary_date,
              A1.ACTIVE_PHYSICIAN_ADVISOR,
              MV.LINE_OF_BUSINESS
    FROM Windsoradm.auth_master a1
    INNER JOIN Windsoradm.auth_phys_advisor ap
    ON a1.auth_number=ap.auth_number
    INNER JOIN windsoradm.prov_master pm
    ON ap.seq_prov_id=pm.seq_prov_id
    LEFT JOIN windsoradm.note_master nm
    ON nm.seq_memb_id=a1.seq_memb_id
    INNER JOIN windsoradm.member_mv mv
    ON mv.seq_memb_id=a1.seq_memb_id
    Where mv.Line_of_Business <>'SFS'
    /*AND A1.PLACE_OF_SERVICE IN ('11','21','22','24')*/
    /*AND a1.active_physician_advisor = 'Y'*/
    /*AND (a1.closed_reason ='A06' OR a1.closed_reason is Null)*/
    AND a1.insert_datetime Between To_Date ('04/01/2012', 'MM/DD/YYYY') and To_Date ('04/30/2012','MM/DD/YYYY')
    ORDER BY 1

    I don't know how to use this within my query I put it in as you suggest and get an error: I'm new to these functions can you show me how within my query I should code it? The field Name is A1.service_user_defined_1 There are about 50 Different Codes in a Drop down list within the application that have a different Code and Different Description it appears that the Codes are all 4 character alpha numeric then about 25 to 45 spaces and then the description. Please show me in my code how to get this I wish there was a table I could link to that housed both code and description but who ever created this did not make life easy. Thanks (I also tried the TRIM but could not get it to work ) I know it is because I do not know how to put it within my code to make it work.
    SELECT DISTINCT
              A1.AUTH_NUMBER,
    PM.LAST_NAME,
              A1.AUTH_TYPE,
              A1.PLACE_OF_SERVICE,
              A1.OVERALL_STATUS,
              A1.CLOSED_REASON,
              A1.DENIED_REASON,
    Case
    when A1.DENIED_REASON in ('HS001','HS002') then 'MED NECESS'
    when A1.DENIED_REASON in ('HS004','HS005','HS006','HS007','HS008','HS013','HS014','HS016','HS017','HS019','HS020') then 'Admin Denial'
    when A1.DENIED_REASON is NUll and ap.advisor_decision = 'AAPPR' then 'Approved'
    else 'Unknown'
    end DENIED,
    A1.admit_primary_date,
    A1.service_admit_type AS "IP ADMIT TYPE",
    A1.service_user_defined_1 AS "OP Serv Type",
    regexp_replace('AA01 Behavioral/Mental Health Service', '^[^ ]+ +')from dual,
    ap.contact_date,
         AP.decision_date,
         AP.ADVISOR_DECISION,
              PM.PROVIDER_ID,
         A1.INSERT_DATETIME,
    TO_CHAR (A1.insert_datetime,'MONTH-YY')AS "Month",
    A1.admit_primary_date,
              A1.ACTIVE_PHYSICIAN_ADVISOR,
              MV.LINE_OF_BUSINESS
    FROM Windsoradm.auth_master a1
    INNER JOIN Windsoradm.auth_phys_advisor ap
    ON a1.auth_number=ap.auth_number
    INNER JOIN windsoradm.prov_master pm
    ON ap.seq_prov_id=pm.seq_prov_id
    LEFT JOIN windsoradm.note_master nm
    ON nm.seq_memb_id=a1.seq_memb_id
    INNER JOIN windsoradm.member_mv mv
    ON mv.seq_memb_id=a1.seq_memb_id
    Where mv.Line_of_Business <>'SFS'
    /*AND A1.PLACE_OF_SERVICE IN ('11','21','22','24')*/
    /*AND a1.active_physician_advisor = 'Y'*/
    /*AND (a1.closed_reason ='A06' OR a1.closed_reason is Null)*/
    AND a1.insert_datetime Between To_Date ('04/01/2012', 'MM/DD/YYYY') and To_Date ('04/30/2012','MM/DD/YYYY')
    ORDER BY 1

  • How do I use the message function to text?

    I Want to text from my Ipad. What are the steps? Must the recipient have an Apple device?

    Messages on an iPad will use the iMessage servicve from apple. So your recipients qwill need to have an Apple Devce, and have configured iMessages. And you must have the address they set up messages with to message them.

  • How Can i use the key file Generated by RSACryptoServiceProvider to encrypt with php?

    I need to be able to encrypt data in PHP using a public key generate by .NET(RSACryptoServiceProvider).  I will then decrypt the data later in C# using the private key.
    Code Snippet
    <RSAKeyValue><Modulus>xU5JyaPNDKXI/h/uo5Vk89wZSz3zsB1+c+1IMYIQa+mCmuRCRPuoBI7ODSV2ndP6grfhdrWEzhpZtkI3SThbBh/3t+tfZ2PF8Iyv9ECN07V64nPCiJGhAnfENE+J9UD9Kw5czXHgZcBbpM5N0VfXmLSleaS65DDoNPtoStVy7ss=</Modulus><Exponent>AQAB</Exponent><P>4ScAjVrPZii/6lICAP2yDQiNEmNL74+5AcxNVDI0IombfDPIygrqEWmuDu0pngApQak7XnEnLbaDChILFiHPZQ==</P><Q>4FaYlse+cjrlPD/jk+GsTJeuP7yuQx8ztjVnQWVh6GKQP+uk1dAl6kcZOfLNR6LWwE3CSygt8PthTEw96Zbabw==</Q><DP>XvXtNLE9UjATqYeHEtXtV7Pok/3PVC3A8PIzFzTJaluxeXP51sU9rbRt1hvO9rXIsMnooU+GH7Cfmgq8JEyERQ==</DP><DQ>HXkC/vwq9xLpvuqd2XXSjxV2XQVK16Knxo5pjFvnawJX9S3eMADymj7Q/534firUj9snZXxX3MsJ015I3AFnnQ==</DQ><InverseQ>AM0fVCE3n2FKf2zb3CcDEge1Ko35VvMEL+LXgR87QwO2HScZSuLevGLi2SSAkB1vu8RSNzB028SZReeOZWnq4Q==</InverseQ><D>fI+GKdRNOTTYhQZnw8Im74T+OvArjf2wvUMJlqfD8jyDBYIhDCfL1MTK9KW4Er+moSuxHR5Pb0ZXaKa4/HKlk0aJ1jB2C+jg7zTSuPRNuS16BpVHaJYsQurCwZwElXMum+GxeXK/h3wXWq5HwebjqZr0aLUMZKRcweDPRoVFiRE=</D></RSAKeyValue>
    As you see this code snippet is a xml format private key. at .net platform,which can use encrypt or dencrypt.
    i have try the Extension Crypt RSA ( http://pear.php.net/reference/Crypt_RSA-1.0.0/elementindex_Crypt_RSA.html ) to help me encrypt data by php.but it haven't return a currect result. the data encrypted by php cann't dencrypt by c#.
    does the RSA algorithm provider by Crypt_RSA can give a stand result as c#?
    BTW :i just use the xmlkeystring like this.
    Code Snippet
    <?php
    require_once("Crypt/RSA.php");
    require_once("includes/Utils.class.php");
        $public_key_string = simplexml_load_string("<RSAKeyValue><Modulus>xU5JyaPNDKXI/h/uo5Vk89wZSz3zsB1+c+1IMYIQa+mCmuRCRPuoBI7ODSV2ndP6grfhdrWEzhpZtkI3SThbBh/3t+tfZ2PF8Iyv9ECN07V64nPCiJGhAnfENE+J9UD9Kw5czXHgZcBbpM5N0VfXmLSleaS65DDoNPtoStVy7ss=</Modulus><Exponent>AQAB</Exponent><P>4ScAjVrPZii/6lICAP2yDQiNEmNL74+5AcxNVDI0IombfDPIygrqEWmuDu0pngApQak7XnEnLbaDChILFiHPZQ==</P><Q>4FaYlse+cjrlPD/jk+GsTJeuP7yuQx8ztjVnQWVh6GKQP+uk1dAl6kcZOfLNR6LWwE3CSygt8PthTEw96Zbabw==</Q><DP>XvXtNLE9UjATqYeHEtXtV7Pok/3PVC3A8PIzFzTJaluxeXP51sU9rbRt1hvO9rXIsMnooU+GH7Cfmgq8JEyERQ==</DP><DQ>HXkC/vwq9xLpvuqd2XXSjxV2XQVK16Knxo5pjFvnawJX9S3eMADymj7Q/534firUj9snZXxX3MsJ015I3AFnnQ==</DQ><InverseQ>AM0fVCE3n2FKf2zb3CcDEge1Ko35VvMEL+LXgR87QwO2HScZSuLevGLi2SSAkB1vu8RSNzB028SZReeOZWnq4Q==</InverseQ><D>fI+GKdRNOTTYhQZnw8Im74T+OvArjf2wvUMJlqfD8jyDBYIhDCfL1MTK9KW4Er+moSuxHR5Pb0ZXaKa4/HKlk0aJ1jB2C+jg7zTSuPRNuS16BpVHaJYsQurCwZwElXMum+GxeXK/h3wXWq5HwebjqZr0aLUMZKRcweDPRoVFiRE=</D></RSAKeyValue>");
        $key =new Crypt_RSA_Key(base64_decode($public_key_string->Modulus),base64_decode($public_key_string->Exponent),"public");
        echo "<pre>";
        print_r($key);
        echo "</pre>";
        $rsa_obj = new Crypt_RSA();
        //try encrypt data
        echo "encrypted result is:<br/>".$rsa_obj->encrypt("this is a smple text.",$key)
        ?>
    but the encrypted data cann't decrypt by c#?where is the problem?what should i do with php codes?

    thank you for your reply, i also found this article by google.but this does not meet scene,  thank you all the same.
    i have already solved the problem now,i'd like to post the Solution .infact it's so easy to use rsakey file generated by .net .
    -------------rsa.class.php-------------------
    Code Snippet
    <?php
     * Some constants
    define("BCCOMP_LARGER", 1);
    class RSA
      * PHP implementation of the RSA algorithm
      * (C) Copyright 2004 Edsko de Vries, Ireland
      * Licensed under the GNU Public License (GPL)
      * This implementation has been verified against [3]
      * (tested Java/PHP interoperability).
      * References:
      * [1] "Applied Cryptography", Bruce Schneier, John Wiley & Sons, 1996
      * [2] "Prime Number Hide-and-Seek", Brian Raiter, Muppetlabs (online)
      * [3] "The Bouncy Castle Crypto Package", Legion of the Bouncy Castle,
      *      (open source cryptography library for Java, online)
      * [4] "PKCS #1: RSA Encryption Standard", RSA Laboratories Technical Note,
      *      version 1.5, revised November 1, 1993
      * Functions that are meant to be used by the user of this PHP module.
      * Notes:
      * - $key and $modulus should be numbers in (decimal) string format
      * - $message is expected to be binary data
      * - $keylength should be a multiple of 8, and should be in bits
      * - For rsa_encrypt/rsa_sign, the length of $message should not exceed
      *   ($keylength / 8) - 11 (as mandated by [4]).
      * - rsa_encrypt and rsa_sign will automatically add padding to the message.
      *   For rsa_encrypt, this padding will consist of random values; for rsa_sign,
      *   padding will consist of the appropriate number of 0xFF values (see [4])
      * - rsa_decrypt and rsa_verify will automatically remove message padding.
      * - Blocks for decoding (rsa_decrypt, rsa_verify) should be exactly
      *   ($keylength / 8) bytes long.
      * - rsa_encrypt and rsa_verify expect a public key; rsa_decrypt and rsa_sign
      *   expect a private key.
      * rsa encrypt data
      * @param binary string $message
      * @param unknown_type $public_key
      * @param numbers $modulus
      * @param numbers $keylength
      * @return binary data
     function rsa_encrypt($message, $public_key, $modulus, $keylength)
      $padded = RSA::add_PKCS1_padding($message, true, $keylength / 8);
      $number = RSA::binary_to_number($padded);
      $encrypted = RSA::pow_mod($number, $public_key, $modulus);
      $result = RSA::number_to_binary($encrypted, $keylength / 8);
      return $result;
     function rsa_decrypt($message, $private_key, $modulus, $keylength)
      $number = RSA::binary_to_number($message);
      $decrypted = RSA::pow_mod($number, $private_key, $modulus);
      $result = RSA::number_to_binary($decrypted, $keylength / 8);
      return RSA::remove_PKCS1_padding($result, $keylength / 8);
     function rsa_sign($message, $private_key, $modulus, $keylength)
      $padded = RSA::add_PKCS1_padding($message, false, $keylength / 8);
      $number = RSA::binary_to_number($padded);
      $signed = RSA::pow_mod($number, $private_key, $modulus);
      $result = RSA::number_to_binary($signed, $keylength / 8);
      return $result;
     function rsa_verify($message, $public_key, $modulus, $keylength)
      return RSA::rsa_decrypt($message, $public_key, $modulus, $keylength);
     function rsa_kyp_verify($message, $public_key, $modulus, $keylength)
      $number = RSA::binary_to_number($message);
      $decrypted = RSA::pow_mod($number, $public_key, $modulus);
      $result = RSA::number_to_binary($decrypted, $keylength / 8);
      return RSA::remove_KYP_padding($result, $keylength / 8);
      * The actual implementation.
      * Requires BCMath support in PHP (compile with --enable-bcmath)
     // Calculate (p ^ q) mod r
     // We need some trickery to [2]:
     //   (a) Avoid calculating (p ^ q) before (p ^ q) mod r, because for typical RSA
     //       applications, (p ^ q) is going to be _WAY_ too large.
     //       (I mean, __WAY__ too large - won't fit in your computer's memory.)
     //   (b) Still be reasonably efficient.
     // We assume p, q and r are all positive, and that r is non-zero.
     // Note that the more simple algorithm of multiplying $p by itself $q times, and
     // applying "mod $r" at every step is also valid, but is O($q), whereas this
     // algorithm is O(log $q). Big difference.
     // As far as I can see, the algorithm I use is optimal; there is no redundancy
     // in the calculation of the partial results.
     function pow_mod($p, $q, $r)
      // Extract powers of 2 from $q
      $factors = array();
      $div = $q;
      $power_of_two = 0;
      while(bccomp($div, "0") == BCCOMP_LARGER)
       $rem = bcmod($div, 2);
       $div = bcdiv($div, 2);
       if($rem) array_push($factors, $power_of_two);
       $power_of_two++;
      // Calculate partial results for each factor, using each partial result as a
      // starting point for the next. This depends of the factors of two being
      // generated in increasing order.
      $partial_results = array();
      $part_res = $p;
      $idx = 0;
      foreach($factors as $factor)
       while($idx < $factor)
        $part_res = bcpow($part_res, "2");
        $part_res = bcmod($part_res, $r);
        $idx++;
       array_push($partial_results, $part_res);
      // Calculate final result
      $result = "1";
      foreach($partial_results as $part_res)
       $result = bcmul($result, $part_res);
       $result = bcmod($result, $r);
      return $result;
     // Function to add padding to a decrypted string
     // We need to know if this is a private or a public key operation [4]
     function add_PKCS1_padding($data, $isPublicKey, $blocksize)
      $pad_length = $blocksize - 3 - strlen($data);
      if($isPublicKey)
       $block_type = "\x02";
       $padding = "";
       for($i = 0; $i < $pad_length; $i++)
        $rnd = mt_rand(1, 255);
        $padding .= chr($rnd);
      else
       $block_type = "\x01";
       $padding = str_repeat("\xFF", $pad_length);
      return "\x00" . $block_type . $padding . "\x00" . $data;
     // Remove padding from a decrypted string
     // See [4] for more details.
     function remove_PKCS1_padding($data, $blocksize)
      assert(strlen($data) == $blocksize);
      $data = substr($data, 1);
      // We cannot deal with block type 0
      if($data{0} == '\0')
      die("Block type 0 not implemented.");
      // Then the block type must be 1 or 2
      assert(($data{0} == "\x01") || ($data{0} == "\x02"));
      // Remove the padding
      $offset = strpos($data, "\0", 1);
      return substr($data, $offset + 1);
     // Remove "kyp" padding
     // (Non standard)
     function remove_KYP_padding($data, $blocksize)
      assert(strlen($data) == $blocksize);
      $offset = strpos($data, "\0");
      return substr($data, 0, $offset);
     // Convert binary data to a decimal number
     function binary_to_number($data)
      $base = "256";
      $radix = "1";
      $result = "0";
      for($i = strlen($data) - 1; $i >= 0; $i--)
       $digit = ord($data{$i});
       $part_res = bcmul($digit, $radix);
       $result = bcadd($result, $part_res);
       $radix = bcmul($radix, $base);
      return $result;
     // Convert a number back into binary form
     function number_to_binary($number, $blocksize)
      $base = "256";
      $result = "";
      $div = $number;
      while($div > 0)
       $mod = bcmod($div, $base);
       $div = bcdiv($div, $base);
       $result = chr($mod) . $result;
      return str_pad($result, $blocksize, "\x00", STR_PAD_LEFT);
    ?>
    -------------RSAProcessor.class.php------------------------
    Code Snippet
    <?php
    require_once("rsa.class.php");
    class RSAProcessor
     private $public_key = null;
     private $private_key = null;
     private $modulus = null;
     private $key_length = "1024";
     public function __construct($xmlRsakey=null,$type=null)
             $xmlObj = null;
       if($xmlRsakey==null)
               $xmlObj = simplexml_load_file("xmlfile/RSAKey.xml");
              elseif($type==RSAKeyType::XMLFile)
               $xmlObj = simplexml_load_file($xmlRsakey);
              else
               $xmlObj = simplexml_load_string($xmlRsakey);
             $this->modulus = RSA::binary_to_number(base64_decode($xmlObj->Modulus));
       $this->public_key = RSA::binary_to_number(base64_decode($xmlObj->Exponent));
       $this->key_length = strlen(base64_decode($xmlObj->Modulus))*8;
      * get public key
      * @return string public key
     public function getPublicKey()
      //return base64_encode(RSA::number_to_binary($this->public_key,($this->key_length)/8));
      return $this->public_key;
     public function getPrivateKey()
      //return base64_encode(RSA::number_to_binary($this->private_key,($this->key_length)/8));
      return $this->private_key;
     public function getKeyLength()
      return $this->key_length;
     public function getModulus()
      return $this->modulus;
      * encrypt data
      * @param string $data
      * @return base64 encoded  binary string
     public function encrypt($data)
      return base64_encode(RSA::rsa_encrypt($data,$this->public_key,$this->modulus,$this->key_length));
     public function dencrypt($data)
      return RSA::rsa_decrypt($data,$this->private_key,$this->modulus,$this->key_length);
     public function sign($data)
      return RSA::rsa_sign($data,$this->private_key,$this->modulus,$this->key_length);
     public function verify($data)
      return RSA::rsa_verify($data,$this->public_key,$this->modulus,$this->key_length);
    class RSAKeyType
     const XMLFile = 0;
     const XMLString = 1;
    ?>
    -------------- encrypt data with public key-----------------
    Code Snippet
    <?php
    require_once("RSAProcessor.class.php");
    $processor = new RSAProcessor
    ("<RSAKeyValue><Modulus>m6ljoeWhmnd0oRnsVEH5iNw3B8+vKVu7v7CVfMyf6bnKEzHa62TRmT/baJiSevoI/vgm2ph/s1JrQQTaGiErHicigwSC
    Aw7+i05WFbnz7tOyiiJJVMfsdd+v7Xan9Hiud05FzxoMbM8vpiMHPEIDbGJ1MiXyupTVkz2WcMHyBoJ4S189opktZ43pviUhy0PeuWkyoU7zR54akPmK
    Yg+z5Zr1r7K8lUZ1a3TThfJGxTQR/uZMtZz/q8QF0AANVQ/eyahTv9icBzBoDuncS0Y5l3vqogW1C/ltJvhJpvSn/OgjbRjuixCAptOUmRd13sDWU95/
    x0bMq+Lg68lj2OjJ1Q==</Modulus><Exponent>AQAB</Exponent><P>zfvdBsMLlmo+4PAUYLgSV2xyyVa7ZqFjkJaAE4EbYuH24EoZjrzeiJR++D
    FUT/GUhjfZ5eZ/5e29dXwk0sKUw6nHzBdBtOPp5fr4t5SKLEcWY+J+zLUSOlhG9NUkohFf6+Miy2Y7BLpXVrcl6UwXV0ak8KkTPB2l/aIMwYj5dgc=</
    P><Q>wXV0sA3nDzoSDQA/4QSu/WIlBhkA3jZ7K7G9Z9rpP1A0vH+bZeyCIyo52u8ahGuYbubaizF1XMp+Xv3Mh2KmRbt7+UptwEwbFAUiiad2a312mqm
    j7IJd7gRjGkyzKEm+6fpNeY3NFLNVNhccBqzhNkRoM22xnvQcImD10XVAakM=</Q><DP>wd1HdCLEWCfc0DYE59a2pINUMXyo2foRTDbpifHcRZ+ojAY
    Rsc6+nsssCQnccXVMNVqBgSgEvfGYe+eAfMBX5SN5APPuioJrVGF2DsoFlZC+WPoGH0JYSoNlHO8yEDrMDaXzzH2GFHgQ1XOAged0nFbHzB1FFjJNVL5
    cxRXWu6c=</DP><DQ>QDKuCk5SwubOXqoaiJ15RHRxPNjHRPZnYVSWOgSXKn9/QJ5H/0bA2NKGaHS4JAFgkEzjcRV0kNpRnUwztymxa6qPtWZRjWK0Ca
    y6jVuZHIqB9UkeMLoCWZ3zFSMmwNPYGuUJGLFJwPjR6iU5E64C/nMs8QQR0WHIhFAQwvVZ7uk=</DQ><InverseQ>JckMSlJR10VZdnp83VPjrZ/Z+63
    CGu3tWHm7f4DJ8IwjJWr8FlCpbSwiP6a4e9Upv6bUn/tOj2gY6MMq5G5yTKm2SCRvpUKRu4NCmWAt7vlFv0Z6pkXlTOpzvVjv3v16+dIZOA5Zn+v7+r1
    xbdYdH20KRAbiBO3MfQP7s+VJJvM=</InverseQ><D>W1xrBr2hQOj1wgxWAgoK7IHbprEFrK+TnWmGA46SGPsbmHJ9fAVbY6fwHg7Wgmk4WHXLUCeLY
    /Nu0eWIISfwh60Oe3ls2WC2k4qxyeSvQDBuLNb81U7WAUT9m9E1uK4QMCP3oxs1ybM80zTh7UMNgVK0WG+fbFUomVffcWTTqW+Fu12PEIO+UR/85oq+x
    qVlTzYAEzt1OE9IhkYiRzi99ePXeH2gFltzJ/fb/7jLsDTkhM2eiYTGyOTZmBnen6c6a8b9LFTY4Bc0bGpk5ezHkub6F8p2ZgL/JgIOJMyRZICjDjs+9
    k9PTmMTFsCF6xzHY15Fg25xIDYzIyx1rrRUjQ==</D></RSAKeyValue>",RSAKeyType::XMLString);
    $rs =  $processor->encrypt("Hello,It's Works.");
    echo $rs;
    ?>
    with the front codes.you can easy to encrypt data by public key generate by .net programe.

  • How can i use the jvmti function GetLocalVariable

    can I get the example of using GetLocalVariable?
    (GetLocalObject, GetLocalInt, GetLocalFloat, GetLocalDouble)
    and if get the Value of Object, how can i print the object?
    last, in the java program, can i call the function of jvmti agent?
    I'm studying the exmaple of mtrace(demo of jvmti), I can understand how the jvmti agent works. expecially mtrace.java part. how it can connects java program and jvmti agent.
    if anyone know please let me know. thank you.

    Sorry for the slow reply, this wasn't a posting area I normally look for.
    First you need to use GetLocalVariableTable for a given method. That gives you the variable name to slot mapping (slot is kinda like an offset in the stack for an active stack frame). Then you can use GetLocalVariable to get a value, but you need to know which frame (depth), the topmost or active frame would be 0, and you need to know what thread, thread==NULL means the current thread. You'll need to parse the signature of the variable to know what it's type is and size is before you'd be able to make sense out of the value you get back, which I think is a union of all possible values.
    Hope this helps.
    -kto

  • How can i use the Ratio_to_report function in obiee

    Hi,
    I have to use ratio_to_report function to create the report.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions124.htm.
    this is the link which explains the usage of this function.This function computes the ratio of a value to the sum of a set of values.How can i achieve this in BI
    Please help me
    Thanks,
    saichand

    Hi Sai,
    One more approach is:
    Use pivot and duplicate the measure in Measures block.
    For Duplicated Measure, go to More Options > Show Data As > Index of > Column
    Even it serves the same purpose...
    Hope you got my point... :)

  • How do I use the copy function in microsoft outlook email?, How do I use the copy function in microsoft outlook email?

    I can get into my Microsoft Outlook email on my Ipad2.  It will not allow me to copy parts of the email to paste into a program called Papermate that I use for my blog.  Can this be done?

    I've copied and pasted between programs. You hold your finger down in the text window or over the text until a little balloon pops up to copy or select all. You will also see two little blue dots, those are 'handles' that you can use to expand the selection box. Select what you want then choose copy
    I've then gone into another program, held down my finger in the text box to bring up the 'paste' option and the text transfers

Maybe you are looking for

  • Iphone not syncing music from itunes. all other devices are, it's just one iphone on my account

    I'm having an issue syncing one iphone with my itunes account. I have several other iphones and an ipod that will sync just fine. I am running Windows 8. There was a glitch earlier when the new ios came out that was resolved and everything was workin

  • Service method  of servlet  is called repetitively as response time is more

    Problem: when we try to retrieve data for a particular input, then the retrieve query takes longer time which is as expected i.e more than five minutes as our data ware house is large and the where clause is very complex. After 5 mins what happens is

  • Vendor Code 1317 Query execution was interrupted MySQL

    An Error was encountered performing the requested operation: Query execution was interrupted Vendor Code 1317 Is this a network issue? A database issue? This is intermittent, for a period I can query tables then I try a new query or click on a differ

  • Replacing Cookie value

    Hi, I need to change a cookie value. My cookie is a session cookie.Its not persistent cookie. Still i m not able to change the value of it. It always reflects the old value. I tried expiring the cookie. Overriding the cookie value by creating a new i

  • Direct execution of the sequence when UI launches?

    Hello all, I would like to ask if it is possible, the open sequence and run UUT's buttons to be removed from the user interface and the selected sequence to be started automatically when the UI launches. To be more precise, I would like after opening