vb.net - How to encrypt in VB and PHP? -


i trying create php code encrypts text , in vb decrypt.

php code:

<?php     if (isset($_post['text'])) {         $buffer = $_post['text'];          $extra = 8 - (strlen($buffer) % 8);         // add 0 padding         if($extra > 0) {             for($i = 0; $i < $extra; $i++) {                 $buffer .= "\0";             }         }          $key = "phpandvb";         $iv = "password";          $fopen = fopen("merda.enc", "w");         $fwrite = fwrite($fopen, mcrypt_cbc(mcrypt_3des, $key, $buffer, mcrypt_encrypt, $iv));         fclose($fopen);     } else {         echo "             <form action='index.php' method='post'>                 <table>                     <tr>                         <td>seu texto:</td>                         <td><textarea name='text'></textarea></td>                     </tr><tr>                         <td colspan='2'><input type='submit' value='enviar!'></td>                 </table>             </form>         ";     } ?> 

vb code

imports system.io imports system.security.cryptography imports system.text  public class encryptionanddecryptionclass      public key(15) byte      function decrypt(byval data() byte) string         dim memorystream new memorystream(data)         dim csdecrypt new cryptostream(memorystream, new tripledescryptoserviceprovider().createdecryptor(key, system.text.encoding.utf8.getbytes("password")), cryptostreammode.read)         dim fromencrypt(data.length) byte         csdecrypt.read(fromencrypt, 0, fromencrypt.length)         return new utf8encoding().getstring(fromencrypt)     end function      function encrypt(byval data string) byte()         dim memorystream new memorystream         dim cstream new cryptostream(memorystream, new tripledescryptoserviceprovider().createencryptor(key, system.text.encoding.utf8.getbytes("password")), cryptostreammode.write)         dim toencrypt byte() = new utf8encoding().getbytes(data)         cstream.write(toencrypt, 0, toencrypt.length)         cstream.flushfinalblock()         dim ret byte() = memorystream.toarray()         cstream.close()         memorystream.close()         return ret     end function      sub createkey(byval strkey string)         dim arrbyte(15) byte         dim ascencod new utf8encoding         dim integer = 0         ascencod.getbytes(strkey, i, strkey.length, arrbyte, i)         dim hashsha new sha1cryptoserviceprovider         dim arrhash() byte = hashsha.computehash(arrbyte)         = 0 15             key(i) = arrhash(i)         next     end sub end class 

i'm not getting use codes together, type of encryption exists in not exists in another, not know how change.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -