How to get SHA256 code for object in dart? - serialization

I need to get sha256 code (hex string) for Object. I can get this for String - the result will be equal (verified on some online sites); But I dont know how to get sha256 for dart Object, not for string. In java this possible to do when you make byte[] from Object, dart doesn't support object serialization. so If somebody knows how can i handle with this, please?

Related

Whats wrong with this lambda expression?

"file" is a Mono object received from RestController, I want to convert it into byte[]
byte[] bytes=file.map(filePart -> filePart.content().map(dataBuffer -> dataBuffer.asByteBuffer().array()}));
it says no instance to variable R exist so that it conforms byte[]
for starters that } near the end makes this not compile!
But also, if file is a Mono, then map will also return a Mono, you will need to .block() to get out a value out.
and then you probably want to figure out how to get rid of that block again, if you really want to do reactive.

is there any way to make this class file generated by byte buddy contains LocalVariableTable?

I am using byte buddy to print logs of methods automaticly,but i found that if i use byte buddy to regenerate class files,the LocalVariableTable will be overwritten and disappear.and that will make springmvc unfunctional because springmvc uses LocalVariableTable to get the names of args of methods,and if there is no LocalVariableTable, the programme will go wrong.so how can byte buddy generate a class file with LocalVariableTable?
here is how I used it:
DynamicType.Builder<?>.method((isPublic()
.and(not(isEquals()))
.and(not(isClone()))
.and(not(isToString()))
.and(not(isHashCode()))
.and(not(isDefaultMethod()))
.and(not(isDefaultConstructor()))
.and(not(isDefaultFinalizer()))
.and(not(isAbstract()))
.and(not(isStatic()))
.and(not(isSetter().or(isGetter()))))
.or(isAnnotatedWith(Hook.class)))
.intercept(Advice.to(MethodHooks.class));
If you use interception, you are defining a new method and the old method is backed-up to another location for being able to invoke it. This includes the debug table where this information is stored. You can however compile a class using the -parameters parameter. This more official information is retained by Byte Buddy.

'Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.'

I'm editing a legacy program in VB when most of my computer programming experience is in C#. The program in question compiles fine but when running I get to a certain function call to a DLL file and I get the following:
System.InvalidCastException: 'Unable to cast object of type 'System.Int32[*]' to type 'System.Int32[]'.'
The arguments that are causing the issue are Dim'd As Integer. The function wants the arguments ByRef As Array. However, even when redefining the arguments As Array it says:
'Unable to cast object of type 'System.Int32[*]' to type 'System.Array'.'
EDIT
To try and give "minimal, complete, and verifiable example" as suggested by ItsPete here is some code.
I am using DA 1 OPC Wrapper DLL. This project is something I had to add a few part numbers to, not something I wrote from scratch.
Dim ConnectedOPCServer As New OPCAutomation.OPCServer
Public OPCItemCollection As OPCAutomation.OPCItems
Public gConnectedGroup As OPCAutomation.OPCGroup
Dim ConnectedServerGroups As OPCAutomation.OPCGroups
Dim ItemServerHandles() As Integer
Dim ItemServerErrors() As Integer
Dim OPCItemIDs() As String
ConnectedOPCServer = New OPCAutomation.OPCServer
ConnectedOPCServer.Connect("Kepware.KEPServerEX.V5")
ConnectedServerGroups = ConnectedOPCServer.OPCGroups
gConnectedGroup = ConnectedServerGroups.Add("Group1")
gConnectedGroup.UpdateRate = 200
gConnectedGroup.IsSubscribed = True
Call Add_OPC_Items() 'This adds tags to the OPC collection by assigning elements of the OPCItemIDs array to tag names
OPCItemCollection = gConnectedGroup.OPCItems
OPCItemCollection.DefaultIsActive = True
OPCItemCollection.AddItems(ItemCount, OPCItemIDs, ClientHandles, ItemServerHandles, ItemServerErrors)
I think that is all that is needed. Like I said...I just expected to add a few part numbers to a drop down selection and not have to dig neck deep into debugging this so I'm kinda out of my depth.
Hans Passant that might be promising. But that looks like it is for C# or C++ and not VB. I dont know how there are many duplicates...searching for Int32[*] didn't return much between Google and Stackoverflow's own search.
And holy crap Jimi that is like a day of reading.

PDFSharp; Add SVG signature to PDF File

I'm using jSignature javascript to save a signature to SVG. Now I'm trying to put that SVG on top of a PDF document over a signature blank.
I'm able to do it by converting the SVG to a file, opening that file with SVG (SVG Rendering Library 2.3.0) and turning it into a stream which I then put onto the PDF with PDFSharp. My issue is that I can't get the SVG Library to load from a string. It has to load from a file. I'm pulling these signatures from a Database along with their form related data.
Dim FileText As String
Dim Bytes() As Byte
Using DB As New wotcDB
FileText = (From t In DB.interviews Where t.ID = 1 Select t.Signature).FirstOrDefault
End Using
Bytes = System.Text.Encoding.ASCII.GetBytes(FileText)
Using DataStream As New System.IO.MemoryStream(Bytes)
svgDocument = Svg.SvgDocument.Open(DataStream) 'Issue
End Using
The error I get is as follows;
Severity Code Description Project File Line Suppression State
Error BC30518 Overload resolution failed because no accessible 'Open' can be called with these arguments:
'Public Shared Overloads Function Open(Of T As {SvgDocument, New})(path As String) As T': Type parameter 'T' cannot be inferred.
'Public Shared Overloads Function Open(Of T As {SvgDocument, New})(stream As Stream) As T': Type parameter 'T' cannot be inferred. WOTC-FE d:\Programming\Applications\frmDebug.vb 54 Active
I hate the idea of creating a file to convert to a graphic when the overloads clearly show that I can use streams. What am I doing incorrectly?
Open the svg file in Notepad and check that it is actually using ASCII encoding. I think it is more likely that it is UTF-8. If so, use
Bytes = System.Text.Encoding.UTF8.GetBytes(FileText)
instead.
I found the answer. It was something I already tried and though failed, but now it works. Since the type wasn't infer able, I had to declare it. I tried doing this as stream and it failed. Well today I decided to work through it and, I got it.
mySVG = SvgDocument.Open(Of SvgDocument)(newStream)
It's so obvious and I tripped over it. So to anyone else having this issue, that solves it. Please note that my program is running Option Explicit, Option Strict.

Message Digest in Objective-C

as I'm a newbie in this field the question may seem to be so stupid, but please forgive me. I want to achieve SHA-512 in Objective-C for an equivalent Java code..Here is the Java Code :
String passwordSalt = "Somesalt";
byte[] bsalt=base64ToByte(passwordSalt);
byte[] passwordToDigestAsBytes=("somepassword").getBytes("UTF-8");
MessageDigest digest = MessageDigest.getInstance("SHA-512");
digest.reset();
digest.update(bsalt);
byte[] = input digest.digest(passwordToDigestAsBytes);
I'm using CC_SHA512 for digest function...but what I need to do for digest.update(bsalt) part? how can I achieve the same functionality in Objective-C?
I'm not familiar with Java's MessageDigest object, but it looks like it's just prepending the salt before the data, which is a very normal way to process this kind of data. So you'd just call CC_SHA512_Update() twice. Once with the salt, and then a second time with the password data. Then you'd call CC_SHA512_Final() to fetch the result.