C++ :: PolarSSL SHA512 Wrapper - Differing Hash Lengths

Apr 10, 2013

I'm trying to write a little C++ wrapper around the PolarSLL SHA-512 / 384 implementation, the source code of which you can view here: [URL] .....

The problem I'm having is that the length of the digest is not always 64 bytes (for sha512) or 49 bytes (for sha384) as it's supposed to be, it often is, but not always.

I have pretty much used the code as it is on PolarSSL's website, except for wrapping it in an "impl" namespace. I also ran the self_tests, which all passed.

Here's the code I'm using to wrap the PolarSSL implementation:

namespace {
void sha4(const std::string& input, const sha_t& type, std::string& result) {
bool is_384 = (type == sha_t::SHA_384);
const unsigned char* in = reinterpret_cast<const unsigned char*>(input.c_str());

[Code] ....

When I do a strchr() for '' on the original (non-hex) values, the pointer position returned is the same as the checksums length, so I'm wondering if perhaps the sha4 implementation would shift bits around and one of them happens to become a '', null terminating the hash early?

View 3 Replies


ADVERTISEMENT

C/C++ :: Calculator With Differing Number Of Variables

Jan 31, 2015

I'm working on an assignment where the user inputs the center coordinates(x,y) for an circular array of (x,y) points. The program performs some calculations, then outputs the position of each point, based on the diameter and center location.

The issue I'm having is that the number of points is a variable(inputted by the user). How to make the program perform the calculations for a different number of points each time.

Code:

// Bolt position Calculator
// Calculates position of bolts on plate using number of points, hole diameter, and (x,y) coordinate of center

#include<iostream>;
#include<math.h>;
#include<cmath>;
#define PI 3.14159
using namespace std;
int main() {
int n,xn,yn
float D,x,y,A;

[Code] ......

View 2 Replies View Related

C++ :: Wrapper Class For DLL?

Jan 27, 2012

I've a plugin (.dll) which converts my CAD models from .mb (Autodesk maya) to .xsi (Softimage) format. To make it work, I start maya application, load plugin (.dll) and convert one at-a-time CAD models to .xsi My question is, can I write a wrapper class in C++ around this .dll, which works as a standalone, and doesn't needs to launch Maya and Convert all the .mb to .xsi ??

and to make things more clear... this .dll is a third party one.... and I'm unaware of its implementation...

View 6 Replies View Related

C++ :: Create A C Wrapper Around A Interface Class?

Mar 14, 2013

I need to create a C Wrapper around a C++_Class and in between needs to be an Interface-Class. The Interface-Class is needed, cause there are more C++_Classes which are kinda equal.

Hierarchicaly it would somehow look like this:

=> XY-Process which is calling the CWrapper
==> CMeasureWrapper.c// <-- CWrapper
===> CMeasureWrapper.h// <-- CWrapper Header
====> IMeasurement.h// <-- Interface-Class
=====> CMeasure.cpp// <-- C++_Class
======> CMeasure.h// <-- C++_Class-Header

My Output after compiling.(files will follow)

// CMeasureWrapper.c | CWrapper
#include "CMeasureWrapper.h"
uint32_t gu32_objectHandle;
uint32_t gu32_measureType;
int32_t addNewMeasureObject(uint32_t u32_measureObjType)
{
int32_t t_status = 0;

[Code]...

It's the first time i'll try to build an CWrapper or even a wrapper. So maybe the Project-Properties need to fit as well.

The project itself is called "Platform" with following settings in:

C/C++ -> Advanced -> Compile As -> "Compile as C++ Code (/TP)"

This property on the CMeasureWrapper.c is switched to:

C/C++ -> Advanced -> Compile As -> "Compile as C Code (/TC)" but only on this file!

I'm not sure if it's necessary, the file is of .c type, so I wasn't sure.

what I am doin wrong? Not just depending on the error output, I mean on the whole project. Is there anything else which will not work with such a combination of CWrapper, Interface and C++_Classes? If there are any questions, just throw them at me

View 2 Replies View Related

C++ :: Implement Simple Wrapper For Logging Function

Jul 22, 2014

I need to implement simple wrapper for logging function log(const char *). So the solution is below:

#include <stdio.h>
#include <sstream>
using namespace std;
void log(const char * str){ printf(str);}

[Code] ...

So, according to standard the temporary objects should not be destroyed before full expression execution (expression whitch is not a part of another expression).

The question is: is StreamLogger() << "foo1" << "foo2" << "foo3"; full expression or not?

View 2 Replies View Related

C/C++ :: Right Triangle Program - Computing Lengths Of Sides

May 5, 2014

I made a simple program to compute the lengths of a triangles sides, but when I enter 30 for angle and 10 for hypotenuse I get the opposite side is -9.880316 and the adjacent is 1.542514.

#include <stdio.h>
#include <math.h>
main() {
float angle;
float hypotenuse;
float adjacent;
float opposite;

[Code] ....

View 2 Replies View Related

C :: Access C++ Objects By Using Wrapper And Externals - Linking Error

Feb 13, 2013

My goal is accessing c++ objects within c by using wrapper and externals. To get the pointer to the c++ object I use a type "void *".

But i get an error while linking: undefined reference to "create_mycpp".

Should I take an other way to access c++ objects?

Code:
//-------------------------------------
//mycpp.cpp
#include "mycpp.h"
Mycpp::void func(int i)
{
i += 1;

[Code] ....

View 7 Replies View Related

C++ :: Tree Arrays Of Same Even Lengths And Adds Values At Odd Indexes

Oct 22, 2013

I am trying a program with that takes tree arrays of same even lengths and adds the values at odd indexes and save at even index of 3rd array and voice versa........

what will be the logic i have tried it a lot of time not worked................

View 3 Replies View Related

C/C++ :: Program To Print Histogram Of Lengths Of Words In Its Input

Mar 4, 2014

Write a program to print a histogram of the lengths of words in its input. It is easy to draw the histogram with the bars horizontal; a vertical orientation is more challenging.

See [URL] ....

I'm trying to do this exercise from K&R on my own (with my own code), but I'm receiving a signal (Illegal instruction (Core dumped)) when the input is too large.

#include <stdio.h>
#define MAXWORDLENGTH 10
int main(void) {
int c; /* Character read */
long length[MAXWORDLENGTH + 1];
int reading_word = 0;
int word_size = 0;

[Code] ....

Where the problem might be occurring. I tried debugging with GDB but found no useful information.

Program received signal SIGILL, Illegal instruction.
0x00007ffff7a3b76e in __libc_start_main (main=0x4005d4 <main>, argc=1,
ubp_av=0x7fffffffe2a9, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffe298) at libc-start.c:258
258libc-start.c: No such file or directory.

The program output is also wrong when tested with the code provided at the link given above.

View 7 Replies View Related

C :: Create A Program That Asks User To Input Integer Lengths Of Three Sides Of A Triangle

Sep 6, 2013

C programming: I want to creat a program that asks the user to input the integer lengths of three sides of a triangle, and if so whether the triangle is a right-angled, acute or obtuse one. i am having some doubts about the if, else if statements. I never seem to know how and in what order to use them.

Code:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(int argc, char *argv[]){
int SideA;
int SideB;
int SideC;
}

[code]....

View 14 Replies View Related

C :: How To Add New Value To Hash Table

Apr 18, 2013

I have a problem with this function that adds a new value to the hash table or updates its data if the value already exists:

Code:

int tab_add(tab_disp *td, const object *value) the function should return:
TABDISP_OK if the value is correctly added, or TABDISP_ERROR if memory error, or TABDISP_INVALID if pointer td = NULL

The type of structure I am using is the following:

Code:

typedef struct {
char key[25];
char value[100];
} object;

[code]....

View 2 Replies View Related

C :: How To Generate Hash Table

Jul 29, 2013

Code: I have these two columns.

ID Group
0 2
1 2
2 3
3 4
4 4
5 4
6 4
7 4 Code: I want to store ID values on the bases of same Group, like we do in Hash table (key, value) .

Group ID
2 0,1
3 2
4 3,4,5,6,7

so when i said key 2 it will give me 0,1. how can i do it. As first i thought that i can use array of array but then how i can store the value of key. Now I am thinking of hash but i don't know how I will store and retrieve these values.

View 5 Replies View Related

C++ :: Hash Tables And Queues

Jun 3, 2013

For my homework I need to create a hash table with a size of 7. I also need to create a queue that holds 3 names maximum for each table position

View 1 Replies View Related

C++ :: Duplicates In Hash Table

Feb 24, 2013

I am having problems with this function:

bool HashTable::insert(char const * const key, const Player& aPlayer) {
//calculate the insertion position (the index of the array)
size_t index = calculateIndex(key);
for(int i=0; i < capacity; i++) {

[Code] ....

The inserting part works just fine, but the checking for duplicates where I compare the two values is crashing my program.

View 1 Replies View Related

C++ :: Hash Function Implementation

Aug 26, 2013

I was trying to implement a hash function in c++. This is just for learning purposes and not for a class project or assignment question. I had some questions before I started programming it:

1) Is it meaningful to have a hash function which maps string to string, string to int, int to int, float to int?
2) Can we have a template implementation which does element to element hashing?

I looked at several sources for a clear understanding of concepts and implementation technique but could not find a good source for reading about hashing.

View 3 Replies View Related

C/C++ :: PJW Algorithm Of Hash Table

Jul 28, 2012

I have a doubt in the PJW algorithm of the Hash Table.

What is the logic in shifting the bytes by this specified number as specified in the pjw algorithm.

View 1 Replies View Related

Visual C++ :: How To Define A Hash Map

May 15, 2014

I want a speed of O(1) in search, insertion and deletion.

is std::map<> the way to go?

View 4 Replies View Related

C++ :: Get 15 Names And Then Hash Them - Segmentation Fault

May 3, 2013

The point of this code is to get 15 names and then hash them. After one name is entered I get a segmentation Fault and the program crashes.

Code:
//driver file
#include <iostream>
#include <vector>
#include <string>
using namespace std;

[Code] ....

View 7 Replies View Related

C++ :: Construct Simple Hash Function?

Jun 3, 2013

How to construct a simple hash function ? When the program executes, it will ask for your name. Type your name and it will print out a "hash code" (a number) from that name.

View 2 Replies View Related

C++ :: Retrieve Object From Hash Table

Feb 25, 2013

I'm trying to retrieve the Player object from my hash table so I can edit the content of that object. Here is what I have.

Player* HashTable::retrieve(char * key, Player& aPlayer) {
//calculate the retrieval position (the index of the array)
size_t index = calculateIndex(key);
//search for the data in the chain (linked list)
node * curr = table[index];
char id[100];

[Code] .....

Here I'm calling the retrieve and I need to return a pointer of that object.

Player* PlayerDB::FetchPlayer(char* name) {
Player* info = new Player();
out << "Fetching player " << """ << name << "" -- ";
if(h.retrieve(name, *info)) {
out << "Success!" << endl;

[Code] .....

And here is my call in main.
Player* outPlayer = NULL;
outPlayer = pdb.FetchPlayer("Sappho");
if (outPlayer != NULL) {
outPlayer->LevelUp();
}

I'm just trying to change the actual level of the player using the LevelUp function, but right now it is not making that change. I've been told I need to return a reference of the object in my retrieve function, but I thought that was what I was doing already.

View 3 Replies View Related

C++ :: Runtime Error In Hash Table

Apr 25, 2013

I am getting a strange runtime error when trying to run my hash table program. I have it separated in 3 separate files. I believe I have narrowed down where the error is occurring. It is either happening in insert(const &string s) or in the implementation of vector<list<string>> ht. I would appreciate some input. This is the implementation of insert():

void HTable::insert(const string &s) {
int h = hash(s);
cout<<h<<endl;
list<string> &tempList = ht[h];

[Code] .....

And it is giving me some sort of compilation error saying I cannot convert a type string to type list.

View 1 Replies View Related

C++ :: Hash Table Remove Function

Apr 11, 2013

I am working on creating a program using HashTables. This is for homework. This is the first time I am using and creating HashTables, so forgive me in advance as to I don't know entirely what I am doing. The main problem I am having right now is incorporating my remove() function. I can get the code to compile, but when I run test the program out, it crashes. The error that I am receiving is list iterator is not decrementable Here is my hashtable class as well as my remove() function. Also need to incorporate a print method.

class HTable
{
public:
HTable(int size);

[Code]....

View 5 Replies View Related

C++ :: Separate Chaining Hash Table?

Nov 28, 2014

my insert() function

template <class T>
class Node
{
public:

[Code]....

View 6 Replies View Related

C++ :: Hash Table Of Function Pointers?

Dec 15, 2014

Is it possible to create a hash table of function pointers so that functions can be referenced by their name (using a string?)

View 2 Replies View Related

C++ :: Generate A Sha256 Hash With Std String?

May 22, 2013

I am trying to generate a sha256 hash with std string, but i can't get this incomplete code puzzle to work [URL] .....

void main() {
string pbData1 = "HELLO";
BYTE* pbOutputBuffer;
CryptoPP::SHA256().CalculateDigest(pbOutputBuffer, (byte*)pbData1.c_str(), pbData1.size());
cout << pbOutputBuffer;
}

my problem is converting 'const char *' to 'const byte *' ..etc

View 1 Replies View Related

C :: Setting Hash-table Entries To NULL?

Apr 21, 2013

Here is my code so far:

Code:
//LINEAR CHAINING OR SEPERATE CHAINING...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define MAX_USERNAME_LEN 15
#define MAX_PASSWORD_LEN 20

[Code] ....

When I compile I get this error:

Code:
simpleauth.c: In function ‘initialize_table’:
simpleauth.c:179:30: error: incompatible types when assigning to type ‘DBEntry’ from type ‘void *’

I am sure its a simple error but I cannot seem to figure out how to set all the entries in the database to NULL. My plan is this:

1. Set all entries to NULL.
2. Check if entry is empty, if empty insert into hash-location, if not increment until empty...

Part 2 seems easy to me, but I cannot set them to empty....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved