Thread: VB.NET to C++ (Linux) code conversion
im having small problem. writing program registration system vb.net app. works great need generate same codes on web aswell. 2 of functions im using bit confusing me. me out on porting these 2 functions php or linux executable call php script.
here 2 functions.
code:private function tripledesencode(byval value string, byval key string) string dim des new security.cryptography.tripledescryptoserviceprovider des.iv = new byte(7) {} dim tiv() byte = new byte(-1) {} dim pdb new security.cryptography.passwordderivebytes(key, tiv) des.key = pdb.cryptderivekey("rc2", "md5", 128, new byte(7) {}) dim ms new io.memorystream((value.length * 2) - 1) dim encstream new security.cryptography.cryptostream(ms, des.createencryptor(), security.cryptography.cryptostreammode.write) dim plainbytes byte() = encoding.utf8.getbytes(value) encstream.write(plainbytes, 0, plainbytes.length) encstream.flushfinalblock() dim encryptedbytes(cint(ms.length - 1)) byte ms.position = 0 ms.read(encryptedbytes, 0, cint(ms.length)) encstream.close() des = nothing pdb = nothing ms = nothing encstream = nothing plainbytes = nothing return convert.tobase64string(encryptedbytes) encryptedbytes = nothing end function private function tripledesdecode(byval value string, byval key string) string dim des new security.cryptography.tripledescryptoserviceprovider des.iv = new byte(7) {} dim pdb new security.cryptography.passwordderivebytes(key, new byte(-1) {}) des.key = pdb.cryptderivekey("rc2", "md5", 128, new byte(7) {}) dim encryptedbytes byte() = convert.frombase64string(value) dim ms new io.memorystream(value.length) dim decstream new security.cryptography.cryptostream(ms, des.createdecryptor(), security.cryptography.cryptostreammode.write) decstream.write(encryptedbytes, 0, encryptedbytes.length) decstream.flushfinalblock() dim plainbytes(cint(ms.length - 1)) byte ms.position = 0 ms.read(plainbytes, 0, cint(ms.length)) decstream.close() des = nothing pdb = nothing ms = nothing decstream = nothing return encoding.utf8.getstring(plainbytes) plainbytes = nothing end function
you should able run vb.net code in linux, myself on webserver. need install mono (linux version of .net framework).http://www.mono-project.com/main_page
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk VB.NET to C++ (Linux) code conversion
Ubuntu
Comments
Post a Comment