Search Results

Search found 499 results on 20 pages for 'bird jaguar iv'.

Page 6/20 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How to get compatibility between C# and SQL2k8 AES Encryption?

    - by Victor Rodrigues
    I have an AES encryption being made on two columns: one of these columns is stored at a SQL Server 2000 database; the other is stored at a SQL Server 2008 database. As the first column's database (2000) doesn't have native functionality for encryption / decryption, we've decided to do the cryptography logic at application level, with .NET classes, for both. But as the second column's database (2008) allow this kind of functionality, we'd like to make the data migration using the database functions to be faster, since the data migration in SQL 2k is much smaller than this second and it will last more than 50 hours because of being made at application level. My problem started at this point: using the same key, I didn't achieve the same result when encrypting a value, neither the same result size. Below we have the full logic in both sides.. Of course I'm not showing the key, but everything else is the same: private byte[] RijndaelEncrypt(byte[] clearData, byte[] Key) { var memoryStream = new MemoryStream(); Rijndael algorithm = Rijndael.Create(); algorithm.Key = Key; algorithm.IV = InitializationVector; var criptoStream = new CryptoStream(memoryStream, algorithm.CreateEncryptor(), CryptoStreamMode.Write); criptoStream.Write(clearData, 0, clearData.Length); criptoStream.Close(); byte[] encryptedData = memoryStream.ToArray(); return encryptedData; } private byte[] RijndaelDecrypt(byte[] cipherData, byte[] Key) { var memoryStream = new MemoryStream(); Rijndael algorithm = Rijndael.Create(); algorithm.Key = Key; algorithm.IV = InitializationVector; var criptoStream = new CryptoStream(memoryStream, algorithm.CreateDecryptor(), CryptoStreamMode.Write); criptoStream.Write(cipherData, 0, cipherData.Length); criptoStream.Close(); byte[] decryptedData = memoryStream.ToArray(); return decryptedData; } This is the SQL Code sample: open symmetric key columnKey decryption by password = N'{pwd!!i_ll_not_show_it_here}' declare @enc varchar(max) set @enc = dbo.VarBinarytoBase64(EncryptByKey(Key_GUID('columnKey'), 'blablabla')) select LEN(@enc), @enc This varbinaryToBase64 is a tested sql function we use to convert varbinary to the same format we use to store strings in the .net application. The result in C# is: eg0wgTeR3noWYgvdmpzTKijkdtTsdvnvKzh+uhyN3Lo= The same result in SQL2k8 is: AI0zI7D77EmqgTQrdgMBHAEAAACyACXb+P3HvctA0yBduAuwPS4Ah3AB4Dbdj2KBGC1Dk4b8GEbtXs5fINzvusp8FRBknF15Br2xI1CqP0Qb/M4w I just didn't get yet what I'm doing wrong. Do you have any ideas? EDIT: One point I think is crucial: I have one Initialization Vector at my C# code, 16 bytes. This IV is not set at SQL symmetric key, could I do this? But even not filling the IV in C#, I get very different results, both in content and length.

    Read the article

  • C# Program gets stuck

    - by weirdcsharp
    The program never prints out "test" unless I set a breakpoint on it and step over myself. I don't understand what's happening. Appreciate any help. public partial class Form1 : Form { public Form1() { InitializeComponent(); string testKey = "lkirwf897+22#bbtrm8814z5qq=498j5"; string testIv = "741952hheeyy66#cs!9hjv887mxx7@8y"; string testValue = "random"; string encryptedText = EncryptRJ256(testKey, testIv, testValue); string decryptedText = DecryptRJ256(testKey, testIv, encryptedText); Console.WriteLine("encrypted: " + encryptedText); Console.WriteLine("decrypted: " + decryptedText); Console.WriteLine("test"); } public static string DecryptRJ256(string key, string iv, string text) { string sEncryptedString = text; RijndaelManaged myRijndael = new RijndaelManaged(); myRijndael.Padding = PaddingMode.Zeros; myRijndael.Mode = CipherMode.CBC; myRijndael.KeySize = 256; myRijndael.BlockSize = 256; byte[] keyByte = System.Text.Encoding.ASCII.GetBytes(key); byte[] IVByte = System.Text.Encoding.ASCII.GetBytes(iv); ICryptoTransform decryptor = myRijndael.CreateDecryptor(keyByte, IVByte); byte[] sEncrypted = Convert.FromBase64String(sEncryptedString); byte[] fromEncrypt = new byte[sEncrypted.Length + 1]; MemoryStream msDecrypt = new MemoryStream(sEncrypted); CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read); csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length); return Encoding.ASCII.GetString(fromEncrypt); } public static string EncryptRJ256(string key, string iv, string text) { string sToEncrypt = text; RijndaelManaged myRijndael = new RijndaelManaged(); myRijndael.Padding = PaddingMode.Zeros; myRijndael.Mode = CipherMode.CBC; myRijndael.KeySize = 256; myRijndael.BlockSize = 256; byte[] keyByte = Encoding.ASCII.GetBytes(key); byte[] IVByte = Encoding.ASCII.GetBytes(iv); ICryptoTransform encryptor = myRijndael.CreateEncryptor(keyByte, IVByte); MemoryStream msEncrypt = new MemoryStream(); CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write); byte[] toEncrypt = System.Text.Encoding.ASCII.GetBytes(sToEncrypt); csEncrypt.Write(toEncrypt, 0, toEncrypt.Length); csEncrypt.FlushFinalBlock(); byte[] encrypted = msEncrypt.ToArray(); return Convert.ToBase64String(encrypted); } } edit: Tried Debug.WriteLine Debug.WriteLine("encrypted: " + encryptedText); Debug.WriteLine("decrypted: " + decryptedText); Debug.WriteLine("test"); Output: encrypted: T4hdAcpP5MROmKLeziLvl7couD0o+6EuB/Kx29RPm9w= decrypted: randomtest Not sure why it's not printing the line terminator.

    Read the article

  • AES and CBC in PHP

    - by Kane
    I am trying to encrypt a string in php using AES-128 and CBC, but when I call mcrypt_generic_init() it returns false. $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '',MCRYPT_MODE_CBC, ''); $iv_size = mcrypt_enc_get_iv_size($cipher); $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND); $res = mcrypt_generic_init($cipher, 'aaaa', $iv); //'aaaa' is a test key Can someone tell me why is returning 0/false? I read the php documentation and seems correct (http://us.php.net/manual/en/mcrypt.examples.php)

    Read the article

  • How do I get 3 lines of text from a paragraph

    - by Keltex
    I'm trying to create an "snippet" from a paragraph. I have a long paragraph of text with a word hilighted in the middle. I want to get the line containing the word before that line and the line after that line. I have the following piece of information: The text (in a string) The lines are deliminated by a NEWLINE character \n I have the index into the string of the text I want to hilight A couple other criteria: If my word falls on first line of the paragraph, it should show the 1st 3 lines If my word falls on the last line of the paragraph, it should show the last 3 lines Should show the entire paragraph in the degenative cases (the paragraph only has 1 or 2 lines) Here's an example: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph Example, if my index points to BIRD, it should show lines 1, 2, & 3 as one complete string like this: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph If my index points to DOG, it should show lines 3, 4, & 5 as one complete string like this: This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph etc. Anybody want to help tackle this?

    Read the article

  • How do I get 3 lines of text from a paragraph in C#

    - by Keltex
    I'm trying to create an "snippet" from a paragraph. I have a long paragraph of text with a word hilighted in the middle. I want to get the line containing the word before that line and the line after that line. I have the following piece of information: The text (in a string) The lines are deliminated by a NEWLINE character \n I have the index into the string of the text I want to hilight A couple other criteria: If my word falls on first line of the paragraph, it should show the 1st 3 lines If my word falls on the last line of the paragraph, it should show the last 3 lines Should show the entire paragraph in the degenative cases (the paragraph only has 1 or 2 lines) Here's an example: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph Example, if my index points to BIRD, it should show lines 1, 2, & 3 as one complete string like this: This is the 1st line of CAT text in the paragraph This is the 2nd line of BIRD text in the paragraph This is the 3rd line of MOUSE text in the paragraph If my index points to DOG, it should show lines 3, 4, & 5 as one complete string like this: This is the 3rd line of MOUSE text in the paragraph This is the 4th line of DOG text in the paragraph This is the 5th line of RABBIT text in the paragraph etc. Anybody want to help tackle this?

    Read the article

  • WordPress: Related Posts by Tags, but in the Same Categories

    - by Norbert
    I'm using the script below to get related posts by tags, but noticed that if I have a picture of a bird tagged white and a table also tagged white, the table will show up in the related posts section of the bird. Is there a way to only get posts that match at least one of the categories, so bird and table won't be related, unless they share one category? I tried setting an category__in array inside $args, but no luck! <?php $tags = wp_get_post_tags($post->ID); if ($tags) { $tag_ids = array(); foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id; $args=array( 'tag__in' => $tag_ids, 'post__not_in' => array($post->ID), 'showposts'=>6, // Number of related posts that will be shown. 'caller_get_posts'=>1 ); $my_query = new wp_query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) { $my_query->the_post(); ?> <?php if ( get_post_meta($post->ID, 'Image', true) ) { ?> <a style="text-decoration: none;" href="<?php the_permalink(); ?>"> <img style="max-height: 125px; margin: 15px 10px; vertical-align: middle;" src="<?php bloginfo('template_directory'); ?>/scripts/timthumb.php?src=<?php echo get_post_meta($post->ID, "Image", $single = true); ?>&w=125&zc=1" alt="" /> </a> <?php } ?> <?php } } } ?>

    Read the article

  • If statement question iphone?

    - by NextRev
    I am creating a game where where you complete shapes and the area gets filled in. However, if there is an enemy bird within your shape, it will not fill in. I want to make it so that if you do trap a bird within your shape, you will lose a life. How can I write an if statement that pretty much says if the below code doesn't take place, then you lose a life. If it helps losing a life is called doDie in my code. -(void)fillMutablePath{ CGPoint movePoint = CGPointFromString([pointsToFillArray objectAtIndex:0]); CGPathMoveToPoint(fillPath, NULL, movePoint.x, movePoint.y); for (int i=0; i<[pointsToFillArray count]; i++) { CGPoint tempPoint = CGPointFromString([pointsToFillArray objectAtIndex:i]); CGPathAddLineToPoint(fillPath, NULL, tempPoint.x, tempPoint.y); } CGContextAddPath(gameViewObj._myContext, fillPath); CGContextFillPath(gameViewObj._myContext); CGPathRelease(fillPath); [pointsToFillArray removeAllObjects]; } if(fillMutablePath doesn't take place when making a shape){ [self doDie]; } Like i said above, the reason fillMutablePath wouldn't take place is because a bird would be trapped within the shape. Any help would be much appreciated!!

    Read the article

  • HTTP 500 ERROR on CAS Server while setting SSLVerifyClent as "required"

    - by Huiyu.Bird
    I have 3 servers, a Apache Server, a JBOSS Server and a CAS Server for SSO. The Apache Server resolve all request with a domain such as www.request.com, and the path of CAS Server is www.request.com/cas, and JBOSS Server is www.request.com/jboss (This app got a CAS client). My problem is if I set SSLVerifyClient require for the NameVirtualHost of www.request.com in my Apache Server, I got a HTTP 500 error during the redirecting to the JBOSS Server(http://www.request.com/jboss), after logined in the CAS login page successfully. But everything goes successfully if there is no SSLVerifyClient require . Error logs of my Apache Server : [Mon Apr 19 17:07:25 2010] [error] Re-negotiation handshake failed: Not accepted by client!? Error logs of my JBOSS Server : 2010-04-19 17:29:57,263 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/jboss].[jsp]] (ajp-0.0.0.0-8009-1) Servlet.service() for servlet jsp threw exception org.jasig.cas.client.validation.TicketValidationException: The CAS server returned no response. at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:162) at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:129) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:103) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.in Any tips will be highly appreciated. Thanks in advance.

    Read the article

  • Android edtftpj/PRo SFTP heap worker problem

    - by Mr. Kakakuwa Bird
    Hi I am using edtftpj-pro3.1 trial copy in my android app to make SFTP connection with the server. After few connections with the server with 5-6 file transfers, my app is crashing with following exception. Is it causing the problem or what could be the problem?? I tried setParallelMode(false) in SSHFTPClient, but it is not working. Exception i'm getting is, 05-31 18:28:12.661: ERROR/dalvikvm(589): HeapWorker is wedged: 10173ms spent inside Lcom/enterprisedt/net/j2ssh/sftp/SftpFileInputStream;.finalize()V 05-31 18:28:12.661: INFO/dalvikvm(589): DALVIK THREADS: 05-31 18:28:12.661: INFO/dalvikvm(589): "main" prio=5 tid=3 WAIT 05-31 18:28:12.661: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x4001b260 self=0xbd18 05-31 18:28:12.661: INFO/dalvikvm(589): | sysTid=589 nice=0 sched=0/0 cgrp=default handle=-1343993192 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.Object.wait(Native Method) 05-31 18:28:12.661: INFO/dalvikvm(589): - waiting on <0x122d70 (a android.os.MessageQueue) 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.Object.wait(Object.java:288) 05-31 18:28:12.661: INFO/dalvikvm(589): at android.os.MessageQueue.next(MessageQueue.java:148) 05-31 18:28:12.661: INFO/dalvikvm(589): at android.os.Looper.loop(Looper.java:110) 05-31 18:28:12.661: INFO/dalvikvm(589): at android.app.ActivityThread.main(ActivityThread.java:4363) 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.reflect.Method.invokeNative(Native Method) 05-31 18:28:12.661: INFO/dalvikvm(589): at java.lang.reflect.Method.invoke(Method.java:521) 05-31 18:28:12.661: INFO/dalvikvm(589): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 05-31 18:28:12.661: INFO/dalvikvm(589): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 05-31 18:28:12.661: INFO/dalvikvm(589): at dalvik.system.NativeStart.main(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): "Transport protocol 1" daemon prio=5 tid=29 NATIVE 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x44774768 self=0x3a7938 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=605 nice=0 sched=0/0 cgrp=default handle=3834600 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.platform.OSNetworkSystem.receiveStreamImpl(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.platform.OSNetworkSystem.receiveStream(OSNetworkSystem.java:478) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.net.PlainSocketImpl.read(PlainSocketImpl.java:565) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:87) 05-31 18:28:12.671: INFO/dalvikvm(589): at org.apache.harmony.luni.net.SocketInputStream.read(SocketInputStream.java:67) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.io.BufferedInputStream.fillbuf(BufferedInputStream.java:157) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.io.BufferedInputStream.read(BufferedInputStream.java:346) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.io.BufferedInputStream.read(BufferedInputStream.java:341) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.A.A((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.A.B((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon.processMessages((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon.startBinaryPacketProtocol((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.transport.TransportProtocolCommon.run((null):-1) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.671: INFO/dalvikvm(589): "StreamFrameSender" prio=5 tid=27 TIMED_WAIT 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x44750a60 self=0x3964d8 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=603 nice=0 sched=0/0 cgrp=default handle=3761648 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): - waiting on <0x399478 (a com.corventis.gateway.ppp.StreamFrameSender) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Object.java:326) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.ppp.StreamFrameSender.run(StreamFrameSender.java:154) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.util.MonitoredRunnable.run(MonitoredRunnable.java:41) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.671: INFO/dalvikvm(589): "SftpActiveWorker" prio=5 tid=25 TIMED_WAIT 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x447522b0 self=0x398e00 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=604 nice=0 sched=0/0 cgrp=default handle=3762704 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Native Method) 05-31 18:28:12.671: INFO/dalvikvm(589): - waiting on <0x3962d8 (a com.corventis.gateway.hostcommunicator.SftpActiveWorker) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Object.wait(Object.java:326) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.SftpActiveWorker.run(SftpActiveWorker.java:151) 05-31 18:28:12.671: INFO/dalvikvm(589): at com.corventis.gateway.util.MonitoredRunnable.run(MonitoredRunnable.java:41) 05-31 18:28:12.671: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.671: INFO/dalvikvm(589): "Thread-12" prio=5 tid=23 NATIVE 05-31 18:28:12.671: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x4474aca8 self=0x115690 05-31 18:28:12.671: INFO/dalvikvm(589): | sysTid=602 nice=0 sched=0/0 cgrp=default handle=878120 05-31 18:28:12.671: INFO/dalvikvm(589): at android.bluetooth.BluetoothSocket.acceptNative(Native Method) 05-31 18:28:12.681: INFO/dalvikvm(589): at android.bluetooth.BluetoothSocket.accept(BluetoothSocket.java:287) 05-31 18:28:12.681: INFO/dalvikvm(589): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:105) 05-31 18:28:12.681: INFO/dalvikvm(589): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:91) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.bluetooth.BluetoothManager.openPort(BluetoothManager.java:215) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.bluetooth.BluetoothManager.open(BluetoothManager.java:84) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.patchcommunicator.PatchCommunicator.open(PatchCommunicator.java:123) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.patchcommunicator.PatchCommunicatorRunnable.run(PatchCommunicatorRunnable.java:134) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.681: INFO/dalvikvm(589): "HfGatewayApplication" prio=5 tid=21 RUNNABLE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=0 dsCount=0 s=N obj=0x4472d9b0 self=0x120928 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=601 nice=0 sched=0/0 cgrp=default handle=1264672 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.Deflate.deflateInit2(Deflate.java:~1361) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.Deflate.deflateInit(Deflate.java:1316) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:127) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.ZStream.deflateInit(ZStream.java:120) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.jcraft.jzlib.ZOutputStream.(ZOutputStream.java:62) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.zipfile.ZipStorer.addStream(ZipStorer.java:211) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.zipfile.ZipStorer.createZip(ZipStorer.java:127) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.HostCommunicator.scanAndCompress(HostCommunicator.java:453) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.HostCommunicator.doWork(HostCommunicator.java:1434) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hf.HfGatewayApplication.doWork(HfGatewayApplication.java:621) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hf.HfGatewayApplication.run(HfGatewayApplication.java:546) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.util.MonitoredRunnable.run(MonitoredRunnable.java:41) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.681: INFO/dalvikvm(589): "Thread-10" prio=5 tid=19 TIMED_WAIT 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x447287f8 self=0x1451b8 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=598 nice=0 sched=0/0 cgrp=default handle=1331920 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.VMThread.sleep(Native Method) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.sleep(Thread.java:1306) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.sleep(Thread.java:1286) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.util.Watchdog.run(Watchdog.java:167) 05-31 18:28:12.681: INFO/dalvikvm(589): at java.lang.Thread.run(Thread.java:1096) 05-31 18:28:12.681: INFO/dalvikvm(589): "Thread-9" prio=5 tid=17 RUNNABLE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=Y obj=0x44722c90 self=0x114e20 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=597 nice=0 sched=0/0 cgrp=default handle=1200048 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.time.Time.currentTimeMillis(Time.java:~77) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.patchcommunicator.PatchCommunicatorState$1.run(PatchCommunicatorState.java:27) 05-31 18:28:12.681: INFO/dalvikvm(589): "Thread-8" prio=5 tid=15 RUNNABLE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=Y obj=0x44722430 self=0x124dd0 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=596 nice=0 sched=0/0 cgrp=default handle=1199848 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.time.Time.currentTimeMillis(Time.java:~80) 05-31 18:28:12.681: INFO/dalvikvm(589): at com.corventis.gateway.hostcommunicator.HostCommunicatorState$1.run(HostCommunicatorState.java:35) 05-31 18:28:12.681: INFO/dalvikvm(589): "Binder Thread #2" prio=5 tid=13 NATIVE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x4471ccc0 self=0x149b60 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=595 nice=0 sched=0/0 cgrp=default handle=1317992 05-31 18:28:12.681: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.681: INFO/dalvikvm(589): "Binder Thread #1" prio=5 tid=11 NATIVE 05-31 18:28:12.681: INFO/dalvikvm(589): | group="main" sCount=1 dsCount=0 s=N obj=0x447159a8 self=0x123298 05-31 18:28:12.681: INFO/dalvikvm(589): | sysTid=594 nice=0 sched=0/0 cgrp=default handle=1164896 05-31 18:28:12.681: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: INFO/dalvikvm(589): "JDWP" daemon prio=5 tid=9 VMWAIT 05-31 18:28:12.691: INFO/dalvikvm(589): | group="system" sCount=1 dsCount=0 s=N obj=0x4470f2a0 self=0x141a90 05-31 18:28:12.691: INFO/dalvikvm(589): | sysTid=593 nice=0 sched=0/0 cgrp=default handle=1316864 05-31 18:28:12.691: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: INFO/dalvikvm(589): "Signal Catcher" daemon prio=5 tid=7 VMWAIT 05-31 18:28:12.691: INFO/dalvikvm(589): | group="system" sCount=1 dsCount=0 s=N obj=0x4470f1e8 self=0x124970 05-31 18:28:12.691: INFO/dalvikvm(589): | sysTid=592 nice=0 sched=0/0 cgrp=default handle=1316800 05-31 18:28:12.691: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: INFO/dalvikvm(589): "HeapWorker" daemon prio=5 tid=5 MONITOR 05-31 18:28:12.691: INFO/dalvikvm(589): | group="system" sCount=1 dsCount=0 s=N obj=0x431b4550 self=0x141670 05-31 18:28:12.691: INFO/dalvikvm(589): | sysTid=591 nice=0 sched=0/0 cgrp=default handle=1316400 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpSubsystemClient.closeHandle((null):~-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpSubsystemClient.closeFile((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpFile.close((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpFileInputStream.close((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at com.enterprisedt.net.j2ssh.sftp.SftpFileInputStream.finalize((null):-1) 05-31 18:28:12.691: INFO/dalvikvm(589): at dalvik.system.NativeStart.run(Native Method) 05-31 18:28:12.691: ERROR/dalvikvm(589): VM aborting 05-31 18:28:12.801: INFO/DEBUG(49): * ** * ** * ** * ** * ** * 05-31 18:28:12.801: INFO/DEBUG(49): Build fingerprint: 'google/passion/passion/mahimahi:2.1-update1/ERE27/24178:user/release-keys' 05-31 18:28:12.801: INFO/DEBUG(49): pid: 589, tid: 601 com.corventis.gateway.hf <<< 05-31 18:28:12.801: INFO/DEBUG(49): signal 11 (SIGSEGV), fault addr deadd00d 05-31 18:28:12.801: INFO/DEBUG(49): r0 00000026 r1 afe13329 r2 afe13329 r3 00000000 05-31 18:28:12.801: INFO/DEBUG(49): r4 ad081f50 r5 400091e8 r6 009b3a6a r7 00000000 05-31 18:28:12.801: INFO/DEBUG(49): r8 000002e8 r9 ad082ba0 10 ad082ba0 fp 00000000 05-31 18:28:12.801: INFO/DEBUG(49): ip deadd00d sp 46937c58 lr afe14373 pc ad035b4c cpsr 20000030 05-31 18:28:12.851: INFO/DEBUG(49): #00 pc 00035b4c /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #01 pc 00044d7c /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #02 pc 000162e4 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #03 pc 00016b60 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #04 pc 00016ce0 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #05 pc 00057b64 /system/lib/libdvm.so 05-31 18:28:12.861: INFO/DEBUG(49): #06 pc 00057cc0 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #07 pc 00057dd4 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #08 pc 00012ffc /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #09 pc 00019338 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #10 pc 00018804 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #11 pc 0004eed0 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #12 pc 0004eef8 /system/lib/libdvm.so 05-31 18:28:12.871: INFO/DEBUG(49): #13 pc 000426d4 /system/lib/libdvm.so 05-31 18:28:12.881: INFO/DEBUG(49): #14 pc 0000fd74 /system/lib/libc.so 05-31 18:28:12.881: INFO/DEBUG(49): #15 pc 0000f840 /system/lib/libc.so 05-31 18:28:12.881: INFO/DEBUG(49): code around pc: 05-31 18:28:12.881: INFO/DEBUG(49): ad035b3c 58234808 b1036b9b f8df4798 2026c01c 05-31 18:28:12.881: INFO/DEBUG(49): ad035b4c 0000f88c ef52f7d8 0004c428 fffe631c 05-31 18:28:12.881: INFO/DEBUG(49): ad035b5c fffe94f4 000002f8 deadd00d f8dfb40e 05-31 18:28:12.881: INFO/DEBUG(49): code around lr: 05-31 18:28:12.881: INFO/DEBUG(49): afe14360 686768a5 f9b5e008 b120000c 46289201 05-31 18:28:12.881: INFO/DEBUG(49): afe14370 9a014790 35544306 37fff117 6824d5f3 05-31 18:28:12.881: INFO/DEBUG(49): afe14380 d1ed2c00 bdfe4630 00026ab0 000000b4 05-31 18:28:12.881: INFO/DEBUG(49): stack: 05-31 18:28:12.881: INFO/DEBUG(49): 46937c18 00000015 05-31 18:28:12.881: INFO/DEBUG(49): 46937c1c afe13359 /system/lib/libc.so 05-31 18:28:12.881: INFO/DEBUG(49): 46937c20 afe3b02c /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c24 afe3afd8 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c28 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c2c afe14373 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c30 afe13329 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c34 afe13329 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c38 afe13380 /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c3c ad081f50 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c40 400091e8 /dev/ashmem/mspace/dalvik-heap/zygote/0 (deleted) 05-31 18:28:12.891: INFO/DEBUG(49): 46937c44 009b3a6a 05-31 18:28:12.891: INFO/DEBUG(49): 46937c48 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c4c afe1338d /system/lib/libc.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c50 df002777 05-31 18:28:12.891: INFO/DEBUG(49): 46937c54 e3a070ad 05-31 18:28:12.891: INFO/DEBUG(49): #00 46937c58 ad06f573 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c5c ad044d81 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): #01 46937c60 000027bd 05-31 18:28:12.891: INFO/DEBUG(49): 46937c64 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c68 463b6ab4 /data/dalvik-cache/data@[email protected]@classes.dex 05-31 18:28:12.891: INFO/DEBUG(49): 46937c6c 463d1ecf /data/dalvik-cache/data@[email protected]@classes.dex 05-31 18:28:12.891: INFO/DEBUG(49): 46937c70 00140450 [heap] 05-31 18:28:12.891: INFO/DEBUG(49): 46937c74 ad041d2b /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c78 ad082f2c /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c7c ad06826c /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c80 00140450 [heap] 05-31 18:28:12.891: INFO/DEBUG(49): 46937c84 00000000 05-31 18:28:12.891: INFO/DEBUG(49): 46937c88 000002f8 05-31 18:28:12.891: INFO/DEBUG(49): 46937c8c 400091e8 /dev/ashmem/mspace/dalvik-heap/zygote/0 (deleted) 05-31 18:28:12.891: INFO/DEBUG(49): 46937c90 ad081f50 /system/lib/libdvm.so 05-31 18:28:12.891: INFO/DEBUG(49): 46937c94 000002f8 05-31 18:28:12.891: INFO/DEBUG(49): 46937c98 00002710 05-31 18:28:12.891: INFO/DEBUG(49): 46937c9c ad0162e8 /system/lib/libdvm.so Thanks & Regards,

    Read the article

  • add a from to backup routine

    - by Gerard Flynn
    hi how do you put a process bar and button onto this code i have class and want to add a gui on to the code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.SqlClient; using System.IO; using System.Threading; using Tamir.SharpSsh; using System.Security.Cryptography; using ICSharpCode.SharpZipLib.Checksums; using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.GZip; namespace backup { public partial class Form1 : Form { public Form1() { InitializeComponent(); } /// <summary> /// Summary description for Class1. /// </summary> public class Backup { private string dbName; private string dbUsername; private string dbPassword; private static string baseDir; private string backupName; private static bool isBackup; private string keyString; private string ivString; private string[] backupDirs = new string[0]; private string[] excludeDirs = new string[0]; private ZipOutputStream zipOutputStream; private string backupFile; private string zipFile; private string encryptedFile; static void Main() { Backup.Log("BackupUtility loaded"); try { new Backup(); if (!isBackup) MessageBox.Show("Restore complete"); } catch (Exception e) { Backup.Log(e.ToString()); if (!isBackup) MessageBox.Show("Error restoring!\r\n" + e.Message); } } private void LoadAppSettings() { this.backupName = System.Configuration.ConfigurationSettings.AppSettings["BackupName"].ToString(); this.dbName = System.Configuration.ConfigurationSettings.AppSettings["DBName"].ToString(); this.dbUsername = System.Configuration.ConfigurationSettings.AppSettings["DBUsername"].ToString(); this.dbPassword = System.Configuration.ConfigurationSettings.AppSettings["DBPassword"].ToString(); //default to using where we are executing this assembly from Backup.baseDir = System.Reflection.Assembly.GetExecutingAssembly().Location.Substring(0, System.Reflection.Assembly.GetExecutingAssembly().Location.LastIndexOf("\\")) + "\\"; Backup.isBackup = bool.Parse(System.Configuration.ConfigurationSettings.AppSettings["IsBackup"].ToString()); this.keyString = System.Configuration.ConfigurationSettings.AppSettings["KeyString"].ToString(); this.ivString = System.Configuration.ConfigurationSettings.AppSettings["IVString"].ToString(); this.backupDirs = GetSetting("BackupDirs", ','); this.excludeDirs = GetSetting("ExcludeDirs", ','); } private string[] GetSetting(string settingName, char delimiter) { if (System.Configuration.ConfigurationSettings.AppSettings[settingName] != null) { string settingVal = System.Configuration.ConfigurationSettings.AppSettings[settingName].ToString(); if (settingVal.Length > 0) return settingVal.Split(delimiter); } return new string[0]; } public Backup() { this.LoadAppSettings(); if (isBackup) this.DoBackup(); else this.DoRestore(); Log("Finished"); } private void DoRestore() { System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Title = "Choose .encrypted file"; fileDialog.Filter = "Encrypted files (*.encrypted)|*.encrypted|All files (*.*)|*.*"; fileDialog.InitialDirectory = Backup.baseDir; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { //string encryptedFile = GetFileName("encrypted"); string encryptedFile = fileDialog.FileName; string decryptedFile = this.GetDecryptedFilename(encryptedFile); //string originalFile = GetFileName("original"); this.Decrypt(encryptedFile, decryptedFile); //this.UnzipFile(decryptedFile, originalFile); } } //use the same filename as the backup except replace ".encrypted" with ".decrypted.zip" private string GetDecryptedFilename(string encryptedFile) { string name = encryptedFile.Substring(0, encryptedFile.LastIndexOf(".")); name += ".decrypted.zip"; return name; } private void DoBackup() { this.backupFile = GetFileName("bak"); this.zipFile = GetFileName("zip"); this.encryptedFile = GetFileName("encrypted"); this.DeleteFiles(); this.zipOutputStream = new ZipOutputStream(File.Create(zipFile)); try { //backup database first if (this.dbName.Length > 0) { this.BackupDB(backupFile); this.ZipFile(backupFile, this.GetName(backupFile)); } //zip any directories specified in config file this.ZipUserSpecifiedFilesAndDirectories(this.backupDirs); } finally { this.zipOutputStream.Finish(); this.zipOutputStream.Close(); } this.Encrypt(zipFile, encryptedFile); this.SCPFile(encryptedFile); this.DeleteFiles(); } /// <summary> /// Deletes any files created by the backup process, namely the DB backup file, /// the zip of all files backuped up, and the encrypred zip file /// </summary> private void DeleteFiles() { File.Delete(this.backupFile); File.Delete(this.zipFile); ///File.Delete(this.encryptedFile); } private void ZipUserSpecifiedFilesAndDirectories(string[] fileNames) { foreach (string fileName in fileNames) { string name = fileName.Trim(); if (name.Length > 0) { Log("Zipping " + name); this.ZipFile(name, this.GetNameFromDir(name)); } } } private void SCPFile(string inputPath) { string sshServer = System.Configuration.ConfigurationSettings.AppSettings["SSHServer"].ToString(); string sshUsername = System.Configuration.ConfigurationSettings.AppSettings["SSHUsername"].ToString(); string sshPassword = System.Configuration.ConfigurationSettings.AppSettings["SSHPassword"].ToString(); if (sshServer.Length > 0 && sshUsername.Length > 0 && sshPassword.Length > 0) { Scp scp = new Scp(sshServer, sshUsername, sshPassword); //Copy a file from local machine to remote SSH server scp.Connect(); Log("Connected to " + sshServer); //scp.Put(inputPath, "/home/wal/temp.txt"); scp.Put(inputPath, GetName(inputPath)); scp.Close(); } else { Log("Not SCP as missing login details"); } } private string GetName(string inputPath) { FileInfo info = new FileInfo(inputPath); return info.Name; } private string GetNameFromDir(string inputPath) { DirectoryInfo info = new DirectoryInfo(inputPath); return info.Name; } private static void Log(string msg) { try { string toLog = DateTime.Now.ToString() + ": " + msg; System.Diagnostics.Debug.WriteLine(toLog); System.IO.FileStream fs = new System.IO.FileStream(baseDir + "app.log", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite); System.IO.StreamWriter m_streamWriter = new System.IO.StreamWriter(fs); m_streamWriter.BaseStream.Seek(0, System.IO.SeekOrigin.End); m_streamWriter.WriteLine(toLog); m_streamWriter.Flush(); m_streamWriter.Close(); fs.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } private byte[] GetFileBytes(string path) { FileStream stream = new FileStream(path, FileMode.Open); byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); stream.Close(); return bytes; } private void WriteFileBytes(byte[] bytes, string path) { FileStream stream = new FileStream(path, FileMode.Create); stream.Write(bytes, 0, bytes.Length); stream.Close(); } private void UnzipFile(string inputPath, string outputPath) { ZipInputStream zis = new ZipInputStream(File.OpenRead(inputPath)); ZipEntry theEntry = zis.GetNextEntry(); FileStream streamWriter = File.Create(outputPath); int size = 2048; byte[] data = new byte[2048]; while (true) { size = zis.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } streamWriter.Close(); zis.Close(); } private bool ExcludeDir(string dirName) { foreach (string excludeDir in this.excludeDirs) { if (dirName == excludeDir) return true; } return false; } private void ZipFile(string inputPath, string zipName) { FileAttributes fa = File.GetAttributes(inputPath); if ((fa & FileAttributes.Directory) != 0) { string dirName = zipName + "/"; ZipEntry entry1 = new ZipEntry(dirName); this.zipOutputStream.PutNextEntry(entry1); string[] subDirs = Directory.GetDirectories(inputPath); //create directories first foreach (string subDir in subDirs) { DirectoryInfo info = new DirectoryInfo(subDir); string name = info.Name; if (this.ExcludeDir(name)) Log("Excluding " + dirName + name); else this.ZipFile(subDir, dirName + name); } //then store files string[] fileNames = Directory.GetFiles(inputPath); foreach (string fileName in fileNames) { FileInfo info = new FileInfo(fileName); string name = info.Name; this.ZipFile(fileName, dirName + name); } } else { Crc32 crc = new Crc32(); this.zipOutputStream.SetLevel(6); // 0 - store only to 9 - means best compression FileStream fs = null; try { fs = File.OpenRead(inputPath); } catch (IOException ioEx) { Log("WARNING! " + ioEx.Message);//might be in use, skip file in this case } if (fs != null) { byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); ZipEntry entry = new ZipEntry(zipName); entry.DateTime = DateTime.Now; // set Size and the crc, because the information // about the size and crc should be stored in the header // if it is not set it is automatically written in the footer. // (in this case size == crc == -1 in the header) // Some ZIP programs have problems with zip files that don't store // the size and crc in the header. entry.Size = fs.Length; fs.Close(); crc.Reset(); crc.Update(buffer); entry.Crc = crc.Value; this.zipOutputStream.PutNextEntry(entry); this.zipOutputStream.Write(buffer, 0, buffer.Length); } } } private void Encrypt(string inputPath, string outputPath) { RijndaelManaged rijndaelManaged = new RijndaelManaged(); byte[] encrypted; byte[] toEncrypt; //Create a new key and initialization vector. //myRijndael.GenerateKey(); //myRijndael.GenerateIV(); /*des.GenerateKey(); des.GenerateIV(); string temp1 = Convert.ToBase64String(des.Key); string temp2 = Convert.ToBase64String(des.IV);*/ //Get the key and IV. byte[] key = Convert.FromBase64String(keyString); byte[] IV = Convert.FromBase64String(ivString); //Get an encryptor. ICryptoTransform encryptor = rijndaelManaged.CreateEncryptor(key, IV); //Encrypt the data. MemoryStream msEncrypt = new MemoryStream(); CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write); //Convert the data to a byte array. toEncrypt = this.GetFileBytes(inputPath); //Write all data to the crypto stream and flush it. csEncrypt.Write(toEncrypt, 0, toEncrypt.Length); csEncrypt.FlushFinalBlock(); //Get encrypted array of bytes. encrypted = msEncrypt.ToArray(); WriteFileBytes(encrypted, outputPath); } private void Decrypt(string inputPath, string outputPath) { RijndaelManaged myRijndael = new RijndaelManaged(); //DES des = new DESCryptoServiceProvider(); byte[] key = Convert.FromBase64String(keyString); byte[] IV = Convert.FromBase64String(ivString); byte[] encrypted = this.GetFileBytes(inputPath); byte[] fromEncrypt; //Get a decryptor that uses the same key and IV as the encryptor. ICryptoTransform decryptor = myRijndael.CreateDecryptor(key, IV); //Now decrypt the previously encrypted message using the decryptor // obtained in the above step. MemoryStream msDecrypt = new MemoryStream(encrypted); CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read); fromEncrypt = new byte[encrypted.Length]; //Read the data out of the crypto stream. int bytesRead = csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length); byte[] readBytes = new byte[bytesRead]; Array.Copy(fromEncrypt, 0, readBytes, 0, bytesRead); this.WriteFileBytes(readBytes, outputPath); } private string GetFileName(string extension) { return baseDir + backupName + "_" + DateTime.Now.ToString("yyyyMMdd") + "." + extension; } private void BackupDB(string backupPath) { string sql = @"DECLARE @Date VARCHAR(300), @Dir VARCHAR(4000) --Get today date SET @Date = CONVERT(VARCHAR, GETDATE(), 112) --Set the directory where the back up file is stored SET @Dir = '"; sql += backupPath; sql += @"' --create a 'device' to write to first EXEC sp_addumpdevice 'disk', 'temp_device', @Dir --now do the backup BACKUP DATABASE " + this.dbName; sql += @" TO temp_device WITH FORMAT --Drop the device EXEC sp_dropdevice 'temp_device' "; //Console.WriteLine("sql="+sql); Backup.Log("Starting backup of " + this.dbName); ExecuteSQL(sql); } /// <summary> /// Executes the specified SQL /// Returns true if no errors were encountered during execution /// </summary> /// <param name="procedureName"></param> private void ExecuteSQL(string sql) { SqlConnection conn = new SqlConnection(this.GetDBConnectString()); try { SqlCommand comm = new SqlCommand(sql, conn); conn.Open(); comm.ExecuteNonQuery(); } finally { conn.Close(); } } private string GetDBConnectString() { StringBuilder builder = new StringBuilder(); builder.Append("Data Source=127.0.0.1; User ID="); builder.Append(this.dbUsername); builder.Append("; Password="); builder.Append(this.dbPassword); builder.Append("; Initial Catalog="); builder.Append(this.dbName); builder.Append(";Connect Timeout=30"); return builder.ToString(); } } } }

    Read the article

  • SFTP in android

    - by Mr. Kakakuwa Bird
    Hi I want to use SFTP in my android project. Can anybody tell me if android [code]already have SFTP library?? Or i have to implement it. If anybody have already done SFTP client in android then please guide me. Thanks in Advance.

    Read the article

  • Creating Service with Bluetooth activation in Android

    - by Mr. Kakakuwa Bird
    Hi I want to create a service in Android which will initially ask user if they want to start Bluetooth and set the Bluetooth discovery. My question is 1) Can I launch in the service following activities? if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, 0); } // Set Phone Discoverable for 300 seconds. Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 600); startActivity(discoverableIntent); 2) I want to set discoverabilty of the phone on for lifetime of application. Is it possible? 3) I want to access empty space available on SD card. How should i do it? Thanks in advance.

    Read the article

  • HTTP 500 a problem on CAS Server while setting SSLVerifyClent as "required"

    - by Huiyu.Bird
    I have 3 server, a Apache Server, a JBOSS Server and a CAS Server for SSO. The Apache Server resolve all request with a domain such as www.request.com, and the path of CAS Server is www.request.com/cas, and JBOSS Server is www.request.com/jboss (This app got a CAS client). My problem is if I set SSLVerifyClient require for the NameVirtualHost of www.request.com in my Apache Server, I got a HTTP 500 error during the redirecting to the JBOSS Server(http://www.request.com/jboss), after logined in the CAS login page successfully. But everything goes successfully if there is no SSLVerifyClient require . Error logs of my Apache Server : [Mon Apr 19 17:07:25 2010] [error] Re-negotiation handshake failed: Not accepted by client!? Error logs of my JBOSS Server : 2010-04-19 17:29:57,263 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/jboss].[jsp]] (ajp-0.0.0.0-8009-1) Servlet.service() for servlet jsp threw exception org.jasig.cas.client.validation.TicketValidationException: The CAS server returned no response. at org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:162) at org.jasig.cas.client.validation.AbstractTicketValidationFilter.doFilter(AbstractTicketValidationFilter.java:129) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jasig.cas.client.authentication.AuthenticationFilter.doFilter(AuthenticationFilter.java:103) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:78) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.in Any tips will be highly appreciated. Thanks in advance.

    Read the article

  • jConfirm and onbeforeunload

    - by Dirty Bird Design
    I have a basic function to alert the user upon refresh, browser back button (except the submit button) or when a link is clicked they will lose form data from a form wizard. <script type="text/javascript"> var okToSubmit = false; window.onbeforeunload = function() { document.getElementById('Register').onclick = function() { okToSubmit = true; }; if(!okToSubmit) return "Using the browsers back button will cause you to lose all form data. Please use the Next and Back buttons on the form"; }; </script> Im using jAlert plug in for alerts and would like to use jConfirm for the function above. When I add jConfirm after "return" it works...for a second. it pops the warning and then the page refreshes and the dialog box goes away. Does anyone know how to fix this?

    Read the article

  • How to put 1000 lightweight server applications in the cloud

    - by Dan Bird
    The company I work for sells a commercial desktop/server app that runs on any non dedicated Windows PC or server and uses Tomcat for all interactions with the application. Customers are asking that we host their instance of the application so they don't have to run it locally on their own servers. The app is lightweight and an average server, in theory, could handle 25-50 instances before users would notice a slowdown. However only 1 instance can run per Windows instance (because the application writes to a common registry branch) so we'd need something like VMWare to create 25-50 Windows instances. We know we eventually need to reprogram to make it truly cloud-worthy but what would you recommend for a server farm or whatever for this? We don't have the setup to purchase our own servers so we must use a 3rd party. We have budgeted $500 - $1000 per year per customer for this service. Thanks in advance for your suggestions, experiences and guidance.

    Read the article

  • Code runs 6 times slower with 2 threads than with 1

    - by Edward Bird
    So I have written some code to experiment with threads and do some testing. The code should create some numbers and then find the mean of those numbers. I think it is just easier to show you what I have so far. I was expecting with two threads that the code would run about 2 times as fast. Measuring it with a stopwatch I think it runs about 6 times slower! void findmean(std::vector<double>*, std::size_t, std::size_t, double*); int main(int argn, char** argv) { // Program entry point std::cout << "Generating data..." << std::endl; // Create a vector containing many variables std::vector<double> data; for(uint32_t i = 1; i <= 1024 * 1024 * 128; i ++) data.push_back(i); // Calculate mean using 1 core double mean = 0; std::cout << "Calculating mean, 1 Thread..." << std::endl; findmean(&data, 0, data.size(), &mean); mean /= (double)data.size(); // Print result std::cout << " Mean=" << mean << std::endl; // Repeat, using two threads std::vector<std::thread> thread; std::vector<double> result; result.push_back(0.0); result.push_back(0.0); std::cout << "Calculating mean, 2 Threads..." << std::endl; // Run threads uint32_t halfsize = data.size() / 2; uint32_t A = 0; uint32_t B, C, D; // Split the data into two blocks if(data.size() % 2 == 0) { B = C = D = halfsize; } else if(data.size() % 2 == 1) { B = C = halfsize; D = hsz + 1; } // Run with two threads thread.push_back(std::thread(findmean, &data, A, B, &(result[0]))); thread.push_back(std::thread(findmean, &data, C, D , &(result[1]))); // Join threads thread[0].join(); thread[1].join(); // Calculate result mean = result[0] + result[1]; mean /= (double)data.size(); // Print result std::cout << " Mean=" << mean << std::endl; // Return return EXIT_SUCCESS; } void findmean(std::vector<double>* datavec, std::size_t start, std::size_t length, double* result) { for(uint32_t i = 0; i < length; i ++) { *result += (*datavec).at(start + i); } } I don't think this code is exactly wonderful, if you could suggest ways of improving it then I would be grateful for that also.

    Read the article

  • Trouble adding success flag to onbeforeunload

    - by Dirty Bird Design
    having issues with onbeforeunload. I have a long form broken into segments via a jquery wizard plug in. I need to pop a confirm dialog if you hit back, refresh, close etc on any step but need it to NOT POP the confirm dialog on click of the submit button. had it working, or at least I thought, it doesn't now. <script type="text/javascript"> var okToSubmit = false; window.onbeforeunload = function() { document.getElementById('Register').onclick = function() { okToSubmit = true; }; if(!okToSubmit) return "Using the browsers back button will cause you to lose all form data. Please use the Next and Back buttons on the form"; }; </script> 'Register' is the submit button ID. Please help!

    Read the article

  • Trying to override onbeforeunload in first step of form wizard

    - by Dirty Bird Design
    This pertains to a form wizard with 5 steps, I don't want the user to hit back and lose form data in any step 2-4. I have added a flag for the submit function and need to add this one for the first step. If they get there by accident and try and leave I dont want the cofirm dialog popping up. <script type="text/javascript"> $(document).ready(function(){ var action_is_post = false; $("form").submit(function () { action_is_post = true; }); //this is the trouble spot. on the first step the "navigation" of the form has a class of current (on step one = current) $(this).ready(function () { if ($("#stepDesc0").is(".current")) { action_is_post = true; } ); window.onbeforeunload = confirmExit; function confirmExit() { if (!action_is_post) return 'Using the browsers back, refresh or close button will cause you to lose all form data. Please use the Next and Back buttons on the form.'; } }); </script>

    Read the article

  • troulbe adding success flag to onbeforeunload

    - by Dirty Bird Design
    having issues with onbeforeunload. I have a long form broken into segments via a jquery wizard plug in. I need to pop a confirm dialog if you hit back, refresh, close etc on any step but need it to NOT POP the confirm dialog on click of the submit button. had it working, or at least I thought, it doesn't now. <script type="text/javascript"> var okToSubmit = false; window.onbeforeunload = function() { document.getElementById('Register').onclick = function() { okToSubmit = true; }; if(!okToSubmit) return "Using the browsers back button will cause you to lose all form data. Please use the Next and Back buttons on the form"; }; </script> 'Register' is the submit button ID. Please help!

    Read the article

  • How to convert m4a file to aac adts file in Xcode?

    - by Bird Hsuie
    I have a mp4 file copied from iPod lib and saved to my Document for my next step, I need it to convert to .mp3 or .aac(ADTS type) I use this code and failed... -(IBAction)compressFile:(id)sender{ NSLog (@"handleConvertToPCMTapped"); // open an ExtAudioFile NSLog (@"opening %@", exportURL); ExtAudioFileRef inputFile; CheckResult (ExtAudioFileOpenURL((__bridge CFURLRef)exportURL, &inputFile), "ExtAudioFileOpenURL failed"); // prepare to convert to a plain ol' PCM format AudioStreamBasicDescription myPCMFormat; myPCMFormat.mSampleRate = 44100; // todo: or use source rate? myPCMFormat.mFormatID = kAudioFormatMPEGLayer3 ; myPCMFormat.mFormatFlags = kAudioFormatFlagsCanonical; myPCMFormat.mChannelsPerFrame = 2; myPCMFormat.mFramesPerPacket = 1; myPCMFormat.mBitsPerChannel = 16; myPCMFormat.mBytesPerPacket = 4; myPCMFormat.mBytesPerFrame = 4; CheckResult (ExtAudioFileSetProperty(inputFile, kExtAudioFileProperty_ClientDataFormat, sizeof (myPCMFormat), &myPCMFormat), "ExtAudioFileSetProperty failed"); // allocate a big buffer. size can be arbitrary for ExtAudioFile. // you have 64 KB to spare, right? UInt32 outputBufferSize = 0x10000; void* ioBuf = malloc (outputBufferSize); UInt32 sizePerPacket = myPCMFormat.mBytesPerPacket; UInt32 packetsPerBuffer = outputBufferSize / sizePerPacket; // set up output file NSString *outputPath = [myDocumentsDirectory() stringByAppendingPathComponent:@"m_export.mp3"]; NSURL *outputURL = [NSURL fileURLWithPath:outputPath]; NSLog (@"creating output file %@", outputURL); AudioFileID outputFile; CheckResult(AudioFileCreateWithURL((__bridge CFURLRef)outputURL, kAudioFileCAFType, &myPCMFormat, kAudioFileFlags_EraseFile, &outputFile), "AudioFileCreateWithURL failed"); // start convertin' UInt32 outputFilePacketPosition = 0; //in bytes while (true) { // wrap the destination buffer in an AudioBufferList AudioBufferList convertedData; convertedData.mNumberBuffers = 1; convertedData.mBuffers[0].mNumberChannels = myPCMFormat.mChannelsPerFrame; convertedData.mBuffers[0].mDataByteSize = outputBufferSize; convertedData.mBuffers[0].mData = ioBuf; UInt32 frameCount = packetsPerBuffer; // read from the extaudiofile CheckResult (ExtAudioFileRead(inputFile, &frameCount, &convertedData), "Couldn't read from input file"); if (frameCount == 0) { printf ("done reading from file"); break; } // write the converted data to the output file CheckResult (AudioFileWritePackets(outputFile, false, frameCount, NULL, outputFilePacketPosition / myPCMFormat.mBytesPerPacket, &frameCount, convertedData.mBuffers[0].mData), "Couldn't write packets to file"); NSLog (@"Converted %ld bytes", outputFilePacketPosition); // advance the output file write location outputFilePacketPosition += (frameCount * myPCMFormat.mBytesPerPacket); } // clean up ExtAudioFileDispose(inputFile); AudioFileClose(outputFile); // show size in label NSLog (@"checking file at %@", outputPath); [self transMitFile:outputPath]; if ([[NSFileManager defaultManager] fileExistsAtPath:outputPath]) { NSError *fileManagerError = nil; unsigned long long fileSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:outputPath error:&fileManagerError] fileSize]; } any suggestion?.......thanks for your great help!

    Read the article

  • applying a var to an if statement jquery

    - by Dirty Bird Design
    Need to apply a var to a statement if its conditions are met, this syntax isn't throwing errors but its not working. <script type="text/javascript"> $(document).ready(function(){ var action_is_post = false; //stuff here $(this).ready(function () { if ($("#stepDesc0").is(".current")) { action_is_post = true; } }); //stuff here </script> should I use something other than .ready? Do I even need the $(this).ready(function ()... part? I need it to apply the var when #stepDesc0 has the class current.

    Read the article

  • Display a summary of form element values before submit

    - by Dirty Bird Design
    Using jquery formtowizard.js with an ajax submit. I want the last step of the form to display a summary of all form fields that were filled out. I can get it to work in isolated test cases, but not in full use. Form <form id="Commission" method="post" action="PHP/CommissionsSubmit.php"> <fieldset id="Initial"> <legend>Enter Your Information</legend> <ul> <li> <label for="FName">First Name*</label><input type="text" name="FName" id="FName"> </li> //repeat many li's </ul> </fieldset> <fieldset> <legend>Second Step</legend> //more li's </fieldset> <fieldset> <legend>Confirmation</legend> <span id="CFName"></span> </fieldset> </form> the jquery to get "#CFName" value $('#FName').keyup(function() { $('#CFName').val($(this).val()); }); I can't get the value to appear in the span "#CFName"... Could this have to do with the "serialize" function or anything going on with my $ajax submit function? its happening before submit... Please help! I apologize, but I've gone back and forth with "#CFName" being a span and an input, using .val and .html respectively

    Read the article

  • Facebook call back function with timeout

    - by Dirty Bird Design
    So I've been getting my ass kicked pretty good with Facebook's moving target of an API. I need to display some hidden content after a person clicks 'like' on a landing page. I can somewhat get this to work, when the user clicks 'like' the normal fb dialogue appears and then goes away immediately and content is displayed. I have 'achieved' this with the following js. <script> FB.Event.subscribe('edge.create', function(href, widget) { document.getElementById('goodies').style.display = "block"; document.getElementById('fb-content').style.display= "block"; document.getElementById('copy').style.display = "none"; }); </script> I cannot find any documentation about a callback event after someone hits "post to facebook" or after the dialogue closes, only afte they hit like. How would I incorporate a setTimeout function into this to give people some time to fill out the fb dialogue? thanks. If anyone has a better way to do this I'm all ears. This is for a business page and I cannot seem to add an app to get an app ID anymore so the API is pretty useless to me at this point. Also, if the url to be liked is a fb page, the callbacks don't seem to fire. Other code used: <html xmlns:fb="http://ogp.me/ns/fb#"> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <fb:like href="onlynonfburl.com" send="false" layout="button_count" width="450" show_faces="false" font="arial"></fb:like>

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >