C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm)
This is a simple program that you will use in the second part of
the assignment. Details of this program is as follows.
A hashing algorithm is simply an algorithm that maps data of an
arbitrary size into a hash value of a fixed size. On your VM, you
should have a program called ”md5sum”, which computes the MD5 hash
of a file (or bytes taken from standard input). One of the most
useful things about md5sum is that it allows you to quickly check
if two files are identical; it is highly improbable that two
different files will have the same md5 hash (while it is certainly
possible, you can safely assume that will not happen in our
class).
Note that you will not use md5sum in your assignment. Rather, in this assignment, you will implement and use the Fowler-Noll-Vo (FNV) hash algorithm, which is much simpler than MD5. The following outlines the FNV Hash algorithm:
def hash(bytes): hash = 0xcbf29ce484222325 for byte in bytes:
hash = hash ^ byte
hash = hash * 0x100000001b3 return hash
Your program should read from standard input until it reaches an
EOF, and output the hash of the bytes it read using your FNV
algorithm. You should add your code to hash.c
In the following example, the user typed “ABC”, and then Enter, and
then pressed “Ctrl-D” to send the EOF to the program’s standard
input:
[jforce@archlinux lab6]$ ./hash ABC 93a0128ba58da453
The program computed 93a0128ba58da453 as the hash of
‘‘ABC\n’’
Fun fact (Not useful to solve this assignment): Hashes are commonly
used in cryptography and computer security. For example, passwords
are often hashed before being put into a database; it is never a
good idea to store plaintext passwords in a database. Storing
plaintext passwords in a database will result in you beingfired.
Note that FNV and MD5 hashes are not cryptographically secure.
Start code:
#include <stdio.h>
int main(){
/*
Fill this code in yourself
*/
printf("%lx\n", hash);
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
const size_t Prime = 0x100000001b3;
const size_t Seed = 0xcbf29ce484222325;
int main()
{
printf("Hello, World!\n");
char str[20];
unsigned char *bytes;
size_t hash;
while(1) {
printf("Enter string:");
scanf("%[^\n]%*c", str);
printf(":%s:", str);
bytes = (unsigned char*)str;
hash = Seed;
for (int i = 0; i < strlen(str); i++) {
hash = hash ^ bytes[i];
hash = hash * Prime;
//printf("%02X ", bytes[i]);
}
printf("%lx\n", hash);
}
printf("\n:");
return 0;
}
C code: hash program (use the Fowler-Noll-Vo (FNV) hash algorithm) This is a simple program that...
1 Objective Build a hashing algorithm that is suitable for use in a Bloom Filter. Please note that while a cryptographic hash is quite common in many Bloom Filters, the hashing algorithm to be implemented is a mix of the the following algorithmic models, specifically, a multiply & rotate hash colloquially known as a murmur hash, and an AND, rolale, & XOR hash colloquially known as an ARX hash. 2 Requirements • Inputs. Read the input file which contains strings...
COSC 359 User Authentication Description A widely used password security technique is the use of hashed passwords and a salt value. This scheme is found on virtually all UNIX variants as well as on a number of other operating systems as shown in Figure 3.1 bellow. To load a new password into the system, the user selects or is assigned a password. This password is combined with a fixed-length salt value. In older implementations, this value is related to the...
This should be in Java Create a simple hash table You should use an array for the hash table, start with a size of 5 and when you get to 80% capacity double the size of your array each time. You should create a class to hold the data, which will be a key, value pair You should use an integer for you key, and a String for your value. For this lab assignment, we will keep it simple Use...
Retrieve program randomAccess.cpp and the data file proverb.txt from the Lab 14 folder. The code is as follows: #include <iostream> #include <fstream> #include <cctype> using namespace std; 327 int main() { fstream inFile("proverb.txt", ios::in); long offset; char ch; char more; do { // Fill in the code to write to the screen // the current read position (with label) cout << "Enter an offset from the current read position: "; cin >> offset; // Fill in the code to move...
Implement in Go language AES encryption mode CBC with providing the packages name for Go language. You can implement AES-ECB Mode (the basic AES) from crypto/aes package and crypto/cipher.Block. You can also get the SHA-256 hash function from crypto/sha256. You can get the secure random numbers generator from crypto/rand package. However, the you will implement both CBC mode and HMAC from scratch. You are NOT allowed to use any libraries or packages to implement these two things for you. You...
Ques) Write a program in c, which meets the following requirements. Requirements 1. Read integer values from stdin, separated by one or more spaces or newlines, until reaching EOF 2. The input is guaranteed to be well-formed. 3. The input contains no more than 80 values. 4. on standard output, render a simple vertical column graph representation of the input values, in order left to right, using hash'#' characters as shown in the examples below. The number of hashes printed...
Please don't use a void fuction and this is a c++ question. Thanks Write a program that reads two input files whose lines are ordered by a key data field. Your program should merge these two files, writing an output file that contains all lines from both files ordered by the same key field. As an example, if two input files contain student names and grades for a particular class ordered by name, merge the information as shown below Using...
Overview: The goal of this assignment is to implement a simple spell checker using a hash table. You will be given the basic guidelines for your implementation, but other than that you are free to determine and implement the exact classes and methods that you might need. Your spell-checker will be reading from two input files. The first file is a dictionary containing one word per line. The program should read the dictionary and insert the words into a hash...
C Program In this assignment you'll write a program that encrypts the alphabetic letters in a file using the Vigenère cipher. Your program will take two command line parameters containing the names of the file storing the encryption key and the file to be encrypted. The program must generate output to the console (terminal) screen as specified below. Command Line Parameters Your program must compile and run from the command line. The program executable must be named “vigenere” (all lower...
The code in project2 is for a program that plays a simple game called Chomp. The programmers of this project have opted to package some of their code in a “module” called chomp.adt, from which the related files cookie.h and cookie.cpp files can be generated. The steps necessary to produce this program are: Run the command csplit chomp.adt "/Split Here/" and copy the resulting file xx00 to cookie.h. Run the command csplit chomp.adt "/Split Here/" and copy the resulting file...