Different HMAC results in C# and C++ - sha1

I have one solution in visual studio 2010. It has two projects, one is written in C# and the other is written in C++. They are completely independent of one another. I am having an issue trying to produce the same result from the two projects. The C++ project can have no .NET dependencies and the two projects must produce the same result using the SHA1 algorithm. I have my C++ code matching this: http://msdn.microsoft.com/en-us/library/windows/desktop/aa382379(v=vs.85).aspx. I would like to replicate the C++ code in the C# project and get the same result.
Currently, I am getting different results. Does anyone have an idea why?

Related

Adding F# projects as references to C++/CLI projects not possible?

I am trying to add an F# project as a reference to a C++/CLI project in VS 2015 but I always get the error that the reference cannot be added because it is incompatible.
Is using F# projects impossible for C++/CLI? Do I have to compile them and add the DLLs to circumvent this?
#Downvoters: Please explain why so I can improve things in the future. Thanks.

Namespace or module "Runtime" not defined

So the "Funscript" page here has a sample. Now I have loaded the sample into my Visual Studio 2012. I am not familiar with Visual Studio .NET and am only learning F# very recently. The last line in the sample pages which is:
do Runtime.Run(components=components, directory="Web")
always throws an error. In fact the Visual Studio IDE(Compiler) cannot seem to recognize Runtime.
If this was a language like Java, one would try to import a library and so I tried using System.Runtime, but still the Visual Studio IDE does not recognize and the line throws an error saying :
"The namespace or module "Runtime" is not defined.
Two questions
How can I get around this?
Is there any link that teaches
F# for the complete beginner that also involves loading external
libraries?
I figured this out. Funscript requires a launcher, which is talked about in the documentation. It is contained in Examples/Shared/Launcher.fs. If you use the .fsproj files that come with funscript, this is all handled automatically.
If you are compiling by hand, just add ../Shared/Launcher.fs before you compile your own file.

Metro style Apps with F#?

In the Build 2011 keynote and demos, they were always talking about C++, C#, Visual Basic and JavaScript. Can't I build Metro style Apps with F#? Or is it safe to say that if it works with C#, then it works with F# as well?
Or is it eligible to say if it works with C# then it works with F# as well?
Yes, that's how it is supposed to work. In addition to javascript and C/C++, any CLS compliant language that runs on top of the CLR will have access to the WinRT API.
Unfortunately in the VS 2011 Express edition you don't get tooling support but I guess this will be added progressively or to other editions:
Don talks about this a little around 7:40 into his talk.
http://channel9.msdn.com/Events/BUILD/BUILD2011/SAC-904T
I had the same question and created a blog post: Create a Metro App in F# (NOT)
There are a few issues:
You cannot reference ordinary .NET dll’s (even in C#). They have to
be have recompiled with a “reference” to the WinRT. Because of this
you cannot reference the F# dll. I think this will be solved when F#
3.0 get released (source: Understanding F# slide from Don Syme at
build).
The ability from F# to create Metro apps. This has to be
built by the F# team. This is an open question. This is the all-F#
approach (In WPF it is today possible but not recommended).
Tool support for creation Metro front-end projects. This will be not the case for the
F# 3.0 release. (source: Understanding F# slide from Don Syme at
build).
Using Visual Studio 11 Developer Preview (Full, not Express), I was able to reference and run F# code from a C# Metro style application with the following caveats:
You will get a build warning saying that the project can't be referenced, even though Visual Studio will still allow you to add it.
You must remove all references to all DLL's in the F# project, including FSharp.Core.
By following these steps it is possible to run F# code from a C# Metro style application, but it is nearly impossible to write any useful code in F# without references to the core language libraries. Let's hope they update the libraries to be WinRT compatible soon.
The question has been answered here:
Windows 8 and F#
Although you cannot create and design Metro apps directly in F#, you can still create so called Portable library in F# with all Models and ViewModels and use it in another Metro projects. It's not ideal, but it works.
I ported my stock chart library for .NET3.5-4.0 to Portable library,it works quite well on Metro with C# Metro application and some my Metro UI bridge.
I'm convinced that I can use F# to make Metro application in many parts.

Web Project for F#

I am building a project system for Visual Studio MVC web projects with controllers written in F#. It comes along pretty cool. I can build and run the apps, but I have a problem with FSharp Language Service.
In the editor it shows the syntax colorization and diagnostic as it should. With one problem - it does not pick up project references. Even though during build it picks them up and successfully builds the project, on the screen it shows the objects/namespaces from the referenced assemblies/projects as unresolved.
If somebody out here has some knowledge about integrating with F# Language service - please help me make it work
In response to Tomas:
The code for F# controllers is in the project file and as I already mentioned I can compile and run it. Originally we kept the F# code in a separate project and desire to get rid of this extra complexity is what prompted this project. It is not a ASP.MVC though it is Bistro MVC.
Edit
BistroMVC now solves this problem in the latest version of the Bistro Designer which is based on the F# project extender
Do you keep your F# source code as part of the Web Project? I'm not sure if this is even possible for ASP.NET MVC, but it was possible in ASP.NET WebForms. With WebForms projects, it didn't work very well (because F# wasn't aware of the project context). I believe it was possible to overcome this with a hacky #if like this:
#if EDITING
#r "Your.Referenced.Library.dll"
#endif
This would serve only as a hint to the editor... However it is much better idea (if it is possible) to write F# controllers in a separate F# project. In that case you shouldn't have any issues (at least I hope so!)
Can you describe what you're doing in more detail? Is this a "flavoring", or a new project system? Are other aspects of the 'project environment' picked up? For example, if you have F# code with
#if DEBUG
let x = 3
#else
let x = 4
#endif
does the coloring change when you change the VS solution from Debug to Release?
(Offhand I am unsure if it will be possible to fully integrate the F# language service into a user-defined project system; if you want more of a discussion, you can email fsbugs#microsoft.com and I'll respond there.)

DELPHI and WANT or NANT

We use cruise control .net to do our Continuous Integration in our Delphi 2006 application. We use a setup similar to the one described here.
QUESTION:
1) What is the best scripting tool/language to use implement the build script?
2) Are there any advantages of using WANT over using NANT?
(NOTE: D2006 is not compatible with MSBuild)
I never used WANT, but NANT works fine with any Delphi version. I presume NANT is also better supported and has more features you can use since it is used more widely then WANT.
BTW: You can still use MSBuild and call dcc32 if you want. In that way it is the same as NANT. If you move to Delphi 2007 MSBuild has a bigger advantage over NANT since the Delphi projects are in the MSBuild format. But even then you can still use NANT as a buildscript. It will just call out to MSBuild to do the separate builds.
Another build tool that is worth checking out is FinalBuilder. It is very complete and knows Delphi. It should, since it is build using Delphi. They also offer a CruiseControl like Continuous Integration solution. The drawback is that FinalBuilder is not free.
Only couple of days back I managed to implement a complex NANT scripts to compile our projects (which uses d7-2009 compilers, VC++ 2005 and subversion). It was very easy to setup and work when used with NantGui .Unlike MSBuild you dont have to have certain version of .NET installed in your system.
For compiling the projects using dcc32, have a look at the delphi3000 article
I used XSL to generate the Cruisecontrol project file automatically. We had a large project with many Delphi applications which already used a common Ant script. So generating the CC project file using a script was a natural solution.
Another Continuous Integration solution which works with Ant (and many others) is TeamCity. It is free up to a certain number of build agents / projects. The user interface is awesome.
I successfully use Ant for many years now for all kinds of Delphi projects, from small component libraries to multi-project multi-tier applications.

Resources