Questions tagged [cryptography]

Questions relating to cryptographic topics such as encryption/decryption and hashing. (Not for use with trivial ciphers.)

Filter by
Sorted by
Tagged with
50
votes
3answers
50k views

Simplified secure encryption of a String

I have two code examples that I wrote for best practices encrypting a string that I'm looking for feedback both in terms of best practices and security. They are both using authenticated encryption. ...
35
votes
6answers
14k views

AES Implementation in C++

I've implemented AES (128, 192 and 256) in C++ and I'm looking to improve the code to make it not "DIY-crypto-bad", if at all possible. I've also been trying to optimize my code, and so far I've ...
29
votes
5answers
22k views

Tiny Encryption Algorithm (TEA) for arbitrary sized data

The TEA is a very simple encryption algorithm requiring little time and space - perfect for embedded systems. There are extensions to it, and every version has its flaws (WEP was based on it), but ...
20
votes
3answers
513 views

Encryption functions based on mcrypt

I learned here that it is unsafe to design encryption algorithms from scratch. Given that advice, I made a pair of encryption functions based on mcrypt: ...
19
votes
3answers
954 views

Enigma machine simulator - improving recursive algorithm performance

I'm new to Haskell and am confused by why my code seems to preform so poorly, and wonder if there's something I've not grasped about the coding philosophy behind the language, or the best way to take ...
17
votes
2answers
15k views

C# AES + RSA Encryption Implementation

I've put together an AES encryption implementation to solve a set of requirements. I believe that I've met the requirements, but I'd like to see if anyone is willing to review the implementation to ...
17
votes
2answers
15k views

Secure password hashing

I have found a password hashing article and an implementation. Is this code secure if I increase the salt to 64 bytes, hash key size to 128 bytes and the iterations to 10000? Are there ...
16
votes
2answers
2k views

ECDH implementation in python

I wrote an implementation of elliptic curve Diffie-Hellman key exchange in python. I would like to know if I could make it faster, cleaner or more secure: ...
15
votes
6answers
10k views

Small one time pad encryption program

This one time pad encryption program I have written (basically just an XOR "encryption" program) seems to be working fine, compiling nicely (gcc -o ./OTP.c), and doing what it's supposed to. However I ...
15
votes
3answers
20k views

RSA algorithm implementation in Python 3

First, a reminder of the RSA algorithm and what my program implements: Take two distinct, large primes p and q Ideally these ...
15
votes
1answer
340 views

Cryptographically-secure super-secret government message transaction machine

-Hello Agent. Are you on a secure line? -Yes, secured. -Good, in 30 seconds the launch codes will be in your e-mail's inbox. You now have the go. Are you ready for the package? -Yes. ...
15
votes
1answer
217 views

Security audit of open-source, RSA Blind Signature library

I've just published a small library implementing the RSA Blind Signature process. Here's the GitHub repo! I needed something portable, and easy enough to use that I could ask other people to ...
14
votes
5answers
3k views

Cryptographically Secure Password Generation in C

I am looking for ways to improve my password generation code written in C. This is in the same vein as my code in C++ and Python with many improvements. I am using ...
14
votes
1answer
9k views

MD5 implementation in C++11

I'm writing a C++ implementation of the MD5 hashing algorithm based on the pseudocode of this wikipedia article. ...
14
votes
1answer
4k views

Decrypting a substitution cipher using n-gram frequency analysis

This is a solution for the June 2015 Community Challenge: a program that decrypts a monoalphabetic substitution cipher. It's written in Python 3, but should be portable to Python 2 if you use ...
13
votes
4answers
2k views

Fast symmetric key cryptography class

I am trying to build a fast cryptography algorithm. The algorithm works fine, but I am worried if there are any potential flaws that might make the algorithm vulnerable to any kind of attack. Here is ...
13
votes
2answers
2k views

A randomized encryption program

I have just created an encryption program with a friend. I wanted to know if anyone here could give me back any feedback on it. Here is how the program works: Imagine you want to encrypt the word '...
13
votes
3answers
3k views

AES implementation

We are using an outdated 3DES algorithm for encryption and I have been tasked with writing a new implementation using AES with a 128bit shared secret. I would like to know if there are any security ...
13
votes
1answer
488 views

.NET 4.5 licensing subsystem using RSA-4096 strong name key, SHA256 signed XML, and assembly signature enforcing

Abstract For the past week I have been looking at taking advantage of the .NET 4.5 improvements to code signing and XML signing to produce a licensing subsystem I can use to license my own products. ...
12
votes
6answers
14k views

Enigma Machine Simulation

This is an Enigma Machine Simulator written in Java: Enigma.java ...
12
votes
4answers
3k views

FileScrambler, a command-line file encryption tool

I decided to try my hand at making an encryption utility, which I lovingly call "FileScrambler". FileScrambler allows the user to encrypt a file (a master-password list, personal diary, or whatever) ...
12
votes
2answers
2k views

Employing 3DES algorithm in Java

I am making a project just for fun that employs the 3DES algorithm in Java. I was wondering if my algorithm looks secure. Is there any advice or feedback you could give me? Do I need to include an IV? ...
12
votes
2answers
834 views

Password hashing method

I am having some issue to use PHP5 password_hash() function. My server is not supporting it, so I am using a function to hash. Is this one secure? ...
12
votes
3answers
8k views

Python implementation of SHA1

Here is a implementation of the cryptographic hash function SHA1 written in Python. It does not use any external libraries, only built-in functions. I know that it would be faster to use an external ...
12
votes
3answers
16k views

Enigma simulator performance

Here is my implementation of a simple 3 rotor Enigma machine in C++: ...
12
votes
2answers
1k views

PHP mcrypt AES encryption wrapper

There are two keys: the main is aes128 and the second is XTEA, used just for randomization of data inside the AES. Randomization is done with secret random key that is not know even if someone knows ...
12
votes
3answers
53k views

Encrypting a string using AES/CBC/PKCS5PADDING

The code below takes a String and encrypts it using AES/CBC/PKCS5PADDING as transformation. I am learning as I go and I have a few questions about my code. Is <...
12
votes
2answers
2k views

Diffie-Hellman in JavaScript

Diffie-Hellman is a key exchange that allows 2 people to share a symmetric key without interaction beforehand. First, a person shares an equation; in this case, we use: $$3^x \mod{17}$$ Next, each ...
12
votes
1answer
14k views

Secure way to store and load password in app config

I am trying to figure out a good way to store and load a password in the application configuration of my C# application. To achieve this I use the BouncyCastle library and the DPAPI from Windows. To ...
11
votes
2answers
2k views

A Caesar cipher in Python3

This code basically just does a Caesar cipher on the contents of the variable "s" with a shift of 1. Sorry if the comments on the code don't explain it well. I'm quite new to Python and I'm not very ...
11
votes
4answers
2k views

Homemade cyraz encryption algorithm

The "Cyraz" encryption algorithm was presented on SOPT community. This algorithm makes a cypher using a private key given in byte[] format with any arbitrary ...
11
votes
2answers
2k views

Baconian Cipher Python Implementation

I have been trying to implement various substitution ciphers in python. I implemented the Baconian cipher using a dictionary in which the plaintext letters are keys and the ciphertext letters are the ...
11
votes
4answers
7k views

Encrypt a byte array

This code is a Frankenstein. I found ten examples done in ten different ways and my requirements were slightly different so even if they were reliable they weren't a copy and paste solution. Encrypt ...
11
votes
4answers
7k views

My own SHA-256 code implementation

I'm worried about my code performance. The code I've written is an implementation of SHA-256 using pseudocode from Wikipedia. It works fine, but I want to speed it up. With a buffer of 4096 bytes, I ...
11
votes
2answers
1k views

Implementation of the Jacobi Symbol in C

I am new to C programming and wrote the following algorithm for the calculation of the Jacobi Symbol. Though there are some faster versions of this algorithm available I am only looking for some ...
11
votes
1answer
10k views

Self-contained SHA-256 implementation in C

I have been looking for a SHA-256 implementation in C with no dependencies (preferably self-contained in a single C-file) with a permissive license but found none to my liking. Since the Wikipedia ...
10
votes
3answers
3k views

Brute force MD5 password checker

I'm trying to create a C# brute force MD5 password checker. If I run it with "test1" without MD5, it completes in 15 seconds. I would like to make it faster, but I'm a c# beginner, and don't know how ...
10
votes
2answers
3k views

Data encryption with python

I am just trying to solve one of the puzzle which is explained below: The sentence if man was meant to stay on the ground god would have given us roots after ...
10
votes
2answers
406 views

Password hashing and matching

I took information from a series of posts and some prior knowledge to implement the following hashing algorithm. However, there is a lot of talk about what implementations are secure and not secure. ...
10
votes
3answers
315 views

What an Enigma! (Machine Simulator)

I've made this some time ago for an assignment and I was wondering how it could be improved both in terms of performance and best practices for C code. ...
10
votes
2answers
288 views

Enigma machine simulator

As my first (keep that in mind!) Haskall program (full code at end) I've written a simple Enigma machine and would like feedback on the core code related to its stepping and encoding — stripped of ...
10
votes
2answers
282 views

Citadel's VisualEncrypt and VisualDecrypt

I was skimming through this paper out of boredom. On pages 5 and 6, the paper shows a simple encryption/decryption scheme that Citadel uses to obfuscate data. The algorithm basically XORs the next ...
10
votes
1answer
2k views

MD5 hash comparison for two folders

Using this page for a starting point into comparing MD5 hash values from files in two different folders, I've put something together that outputs either Copied if ...
10
votes
2answers
632 views

Can this secure, random generator be improved?

This random generator uses cryptographically secure numbers/chars instead of Math.random(). The Javascript code with jQuery works well but I affect clean code ;) It ...
10
votes
1answer
14k views

Using System.Security.Cryptography.ProtectedData, do you see any issue with encryption and encoding?

The application needs to keep a secret which is known to logged in windows user. User enters secret in windows form's text box which is read by application. This is in form of ...
10
votes
1answer
622 views

XTEA Block Cipher

Usually people recommend to never implement cryptographic algorithms yourself unless you are an expert in the field. This of course makes a lot of sense mainly because there are numerous things that ...
10
votes
1answer
18k views

AES-128 encryption class

This is the first time I've written a class in Java to do encryption using AES. Since security is involved I would love it if someone could take a look at it and let me know if anything is wrong with ...
9
votes
2answers
27k views

C# AES Encryption

I've been researching AES encryption a bit over the past several days. The official (MSDN) examples I've seen are encrypting and decrypting using the same AES instance. They don't go in to what to do ...
9
votes
2answers
22k views

User Password Encryption in C#

I am maintaining an old codebase of one of our legacy .Net applications which has a component that encrypts and decrypts user passwords using symmetric key cryptography. Since cryptography is not my ...
9
votes
3answers
5k views

Generate cryptographically secure random numbers in a specific range

A project I'm working on requires generating a random number of \$N\$ length to a very high degree of fair distribution between digits \$[0, 9]\$. That said, I used the ...