I am right now taking a class named Applied Cryptography and our final project is to create a password hashing method using at least one existing algorithm and then add additional steps to make it harder to decrypt.
I am using SHA1 in a Console Application in c#.
The user input is hashed using SHA-1. For each byte of the resulting hash I compute the Fibonacci series of the byte value as int, and append it to a string, if it is positive. If it is not, I append 0.
The result of the Fibonacci computation is hashed using SHA-1 once more.
This is my code so far
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace Proyecto
{
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
StringBuilder fibo = new StringBuilder();
string result1, result2;
result1 = GetSHA1(str);
for (int i = 0; i < GetSHA1(str).Length; i++) fibo.Append((Fibonacci(result1[i]) > 0) ? Fibonacci(result1[i]) : 0);
result2 = GetSHA1(fibo.ToString());
Console.WriteLine(result1);
Console.WriteLine(fibo);
Console.WriteLine(result2);
Console.ReadLine();
}
public static int Fibonacci(int n)
{
int a = 0;
int b = 1;
// In N steps compute Fibonacci sequence iteratively.
for (int i = 0; i < n; i++)
{
int temp = a;
a = b;
b = temp + b;
}
return a;
}
public static string GetSHA1(string str)
{
SHA1 sha1 = SHA1Managed.Create();
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] stream = null;
StringBuilder sb = new StringBuilder();
stream = sha1.ComputeHash(encoding.GetBytes(str));
for (int i = 0; i < stream.Length; i++) sb.AppendFormat("{0:x2}", stream[i]);
return sb.ToString();
}
}
}
I want to know if the additional Fibonacci round improves the strength of the function as a password hashing function, and if not, if you can give me some suggestions.