Posts

Encrypt data using c# and decrypt it using openssl api, why there are lots of trashy padding at the end of decrypted data? -

i using rsa(1024) encrypt/decrypt strings. encryption implemented using public key , written in c#, , decryption implementation c. encrypt string: 86afaecb-c211-4d55-8e90-2b715d6d64b9 and write encrypted data file. then, using openssl api read encrypted data file , decrypt it. however, got output as: 86afaecb-c211-4d55-8e90-2b715d6d64b9oehebjq8fo1amdnor1d3blupyq9wjbaov+m/wvnyzyr pjbkoskoj+4lanpt+spkfk81nsnqebhbjgao4ehnu+pmwl9 it seems there trashy padding @ end of original string. why occurs? , how solve problem? some code snippet shown below: // encrypt { string plaindata = “86afaecb-c211-4d55-8e90-2b715d6d64b9”; rsacryptoserviceprovider rsa = new rsacryptoserviceprovider(); rsa.importparameters(parapub); byte[] testdata = encoding.utf8.getbytes(plaindata); byte[] encrypteddata = rsa.encrypt(testdata, true); filestream pfilestream = null; string filename = "encrypteddata.dat"; pfilestream = new filestream(filename, fi...

java - How to display ArrayList items in a JComponent -

i have this: arraylist lovely = new arrylist(4); lovely.add("tall, short, average"); // line 1 lovely.add("mangoes, apples, bananas"); // line 2 lovely.add("this, that"); // line 3 lovely.add(“1, 2, 3, 4, 5, 6”) // line 4 i'd have array list displayed in such way each category shows in own line, how google list search results. know how this? i'd such displayed in jcomponent, not sure of 1 use, nor how this. java programmers use jtextfields , jtextpanes, or use. help here appreciated. java programmers use jlist . can constuct this: new jlist(lovely.toarray()) it displays each item in separate line in list.

hibernate - Grails - DuplicateKeyException -

i have got following piece of code adds new object database. firstly takes object db , add final object. few lines of code classc c = classc.findbyname(cname) classd d = new classd( name: "whatever", classc: c ) print "aaa\n" classc.withtransaction { c = c.merge() // c.save(failonerror: true, flush: true) } print "bbb\n" // classd.withtransaction { // d = d.merge() // } // print "ccc\n" classd.withtransaction { d.save(failonerror: true, flush: true) } print "ddd\n" i have got following error: aaa bbb 2013-07-31 13:57:14,279 error jobrunshell - job default.1 threw unhandled exception: org.springframework.dao.duplicatekeyexception: different object same identifi...

c++ - Storing path from A*, using operator::new with boost::multi_array -

i'm trying use dynamic memory allocation first time. want allocate memory 2 dim dynamic array, store paths a* function. think array job boost::multi_array. problem seem able allocate memory can't change or access of elements. #include <iostream> #include "boost/multi_array.hpp" typedef boost::multi_array<int, 2> array_type; int main() { array_type *a = new array_type; a->resize( boost::extents[2][2] ); a[1][1] = 2; std::cout << a[1][1] << std::endl; delete a; return 0; } compiler says : c:\coding\code projects\c++\source files\console\main-read.cpp|14|error: no match 'operator<<' in 'std::cout << boost::multi_array_ref<t, numdims>::operator[](boost::multi_array_ref<t, numdims>::index) [with t = int; unsigned int numdims = 2u; boost::multi_array_ref<t, numdims>::reference = boost::detail::multi_array::sub_array<int, 1u>; boost::multi_array_ref<t, num...

highcharts - how to display both the series value in plotoptions mouseover event -

using tooltip formatter can display both series name , value when same done using plotoptions event mouseover not able series name , value tooltip: formatter plotoption: mousover mouseover: function () { $.each(this, function (i, e) { $reporting.html('x: ' + this.x + 'category: ' + this.series.name + ', y: ' +highcharts.numberformat(math.abs(this.y))); }); } example of using in mouseover mouseover: function () { console.log(this); var series = this.series.chart.series, x = this.x, y = this.y, output = 'x: ' + x + 'y: ' + highcharts.numberformat(math.abs(y)); //loop each serie $.each...

How to prevent loading of knockout.js by requirejs? -

i'm using requirejs loading majority modules, need load single script knockout.js old-fashioned manner using: <script src='/path/to/knockout.js' ></script> i have trouble it, when page rendered see markup: <script async="async" type="text/javascript" src="knockout.min.js"></script> but don't want load knockout using require.js. how disable loading using require.js specified script? i found solution: after digging sources of knockout , found interesting pice of code, determine existance of require.js , automatically registers module in require , here guilty chunk of code: // support 3 module loading scenarios if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { // [1] commonjs/node.js var target = module['exports'] || exports; // module.exports node.js factory(target); } else if (typeof d...

sql - Check if variable can be cast against a dynamic datatype -

i creating import application in vb.net sql server 2008 database. trying make import generic possible reduce maintenance in future. therefore gets available columns preset list of tables in can import into. the main problem have gotten point doing error trapping. try check see whether value being imported castable data type of field in database. example, if want import date database mistakenly put address field instead, want pick , alert user. so, have vb datatable same schema database table , value go datatable. below have (which not alot): private sub setvalue(targetdatatable datatable, columnname string, value string) dim dbtype type = targetdatatable.columns(columnname).datatype ???? end sub i have done research reflection still requires me define datatypes. there other ways of doing this? don't think there way automatically type, according msdn there 18 types supported should manageable. private sub setvalue(targetdatatable datata...