Using hashing algorithm in CAPL (CANoe) - capl

I want to implement a hashing algorithm like md5 in CAPL (CANoe). Is there any built-in hashing function in CAPL?

I would suggest to create a CAPL Dll which implements your hash-algorithm in C++ and include it via #pragma library() in your code.
There is an example in "CANoe Sample Configurations\Programming\CAPLdll". For more infos take a look at the chapter "CAPL DLL" in your CANoe help.

There is not a built in hash function in CAPL, the closest I've been able to find is a checksum calculation function. (J1939CalcChecksum) Anyhow you can use the CANoe .NET API, once you are using .NET you can call its hashing libraries.
The reference for CANoe .NET API is in Vector's page in the provided link.

Related

Is there a Rust equivalent to win32crypt.CryptUnprotectData() in Rust

In Python, the pywin32 library provides a module named win32crypt which has a method called CryptUnpotectData to decrypt Windows encrypted data by using the Windows API.
This is how I have applied it in Python:
import win32crypt
# ...
password = win32crypt.CryptUnprotectData(EncrytedPassword, None, None, None, 0)
I have found a binding for the winapi but I can't find the CryptUnprotectData function, the closest I found to an equivalent is the CryptDecrypt function.
Here is my implementation of it in Rust:
extern crate winapi;
let decrypted_password = winapi::um::wincrypt::CryptDecrypt(/* ???? */);
I am not sure how to make use of this function and if it will decrypt my encrypted password string and return it. I would love if more experienced Rust users could shed some light on this for me using an example or explanation.
If you go to the documentation for winapi (linked from the crate page as well as the README), you will find a large search box:
If you type "CryptUnprotectData" into that search box, you will receive 3 results:
Clicking on the first result will lead you to the specific function, CryptUnprotectData. As described in Cannot call CryptDecrypt from the WinApi crate because it could not find the module, you need to use the appropriate feature flag to enable the function (dpapi).
As the README states:
Why is there no documentation on how to use anything?
This crate is nothing more than raw bindings to Windows API. If you
wish to know how to use the various functionality in Windows API, you
can look up the various items on MSDN which is full of detailed
documentation.
Usage of this function is described on MSDN.

Name followed by "::" must be a class or namespace name error [duplicate]

The Thrust function below can get the maximum blocks of for a CUDA launch CUDA 5.0, which is used by Sparse Matrix Vector multiplication(SpMV) in CUSP, and it is a technique for setting up execution for persistent threads. The first line is the header file.
#include <thrust/detail/backend/cuda/arch.h>
thrust::detail::backend::cuda::arch::max_active_blocks(kernel<float,int,VECTORS_PER_BLOCK,TH READS_PER_VECTOR>,THREADS_PER_BLOCK,(size_t)0)
But the function is not supported by CUDA 5.5. Was this technique not supported by CUDA 5.5, or should I use some other function instead?
There was never any supported way to perform this computation in any version of Thrust. Headers inside thrust/detail and identifiers inside a detail namespace are part of Thrust's implementation -- they are not public features. Using them will break your code.
That said, there's some standalone code implementing the occupancy calculator in this repository:
https://github.com/jaredhoberock/cuda_launch_config

Implementation Of Differentiation & Integration(Calculus) In C++

Is there any suitable Algorithm for Integration & Differentiation which I could implement by C++ or C. Just name it with reference. I would be very happy with your answer & explanation if you kind enough to provide a sample code. Thanks in advance.
You can use Calculus c++ library.
It is easy to use. You can declare variables as Variable x="x",y="y";, and functions as Function f=sin(x)*sin(y);.
And you can differentiate it for example with respect to x as
Function dfdx= f->get_partial_derivative(x);

Using XTS algorithm within Botan library for encryption/decryption

The Botan library (botan.randombit.net/) has a number of algorithms for encryption/decryption. I am interested in using the XTS algorithm for encryption/decryption that is available within Botan. However, there is no example provided for XTS usage in the downloaded Botan library. I need to know the XTS algorithm for encryption/decryption from within Botan. I have been able to compile the Botan library on Windows using MSVC. I am also able to build a sample application that links with this library and use the LibraryInitializer function. From this point onwards, I am at loss.
Regards, Saif
This should be all you need to get started with Botan, regardless of what algorithm you're using:
http://botan.randombit.net/filters.html
I'll just put this here...
http://botan.randombit.net/pbkdf.html

WinAPI functions in new .exe

I've been looking recently into creating a new native language. I understand the (very) basics of the PE format and I've grabbed an assembler with a fairly kind interface off the webs, which I've successfully used to implement some simple functions. But I've run into a problem using functions from a library. The only way that I've called library functions from a dynamically compiled function previously is to pass in the function pointer manually- something I can't do if I create PE files and execute them in their own process. Now, I'm not planning on using the CRT, but I will need access to the Win API to implement my own standard libraries. How do I generate a reference to a WinAPI function so that the PE loader will patch it up?
You need to write an import table. It's basically a list of function names that you wish to use in your application. It's pointed to by the PE header. The loader loads the DLL files into the process memory space for you, finds the requested function in their export table and leaves the address for it in the import table. You then usually dereference that and jmp there.
Check out Izelion's assembly tutorial for the full details and for asm examples.
How about starting by emitting C instead of assembly? Then writing directly to ASM is just an optimization.
I'm not being facetious: most compilers turn out some kind of intermediate code before the final native code pass.
I realize you're trying to get away from all the null-delmited rigmarole, but you'll need that for the WinAPI functions anyway.
Re-reading your question: you do realize that you can get the WinAPI function addresses by calling LoadLibrary(), then calling GetProcAddress(), and then setting up the call...right?
If you want to see how to bootstrap this from pure assembly: the old SDKs had ASM sample code, probably the new ones still do. If they don't, the DDK will.

Resources