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
49
votes
3answers
49k 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. ...
34
votes
6answers
12k 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 ...
27
votes
5answers
21k 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
507 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
923 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
14k 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 ...
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
15k 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
2answers
1k 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
1answer
338 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
195 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
7k 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
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
471 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

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 ...
12
votes
2answers
829 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
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
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
3answers
50k 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
1answer
13k 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

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? ...
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
3answers
15k views

Enigma simulator performance

Here is my implementation of a simple 3 rotor Enigma machine in C++: ...
11
votes
3answers
7k 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 ...
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 ...
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
404 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
4answers
5k 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 ...
10
votes
3answers
307 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
277 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
267 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
621 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
452 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 ...
10
votes
1answer
13k 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 ...
9
votes
2answers
26k 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
21k 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
537 views

Encoding and decoding small strings of text

This is supposed to encode and decode small strings of text. Unfortunately, even on a really good laptop, it performs slowly. This might have to do with my looping, or just the sheer computation. It ...
9
votes
1answer
7k 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 ...
9
votes
1answer
1k views

Secure client-side encryption of user content

I am working on a pet project of mine which I've recently revived after a year long hiatus. The application is a note-taking application with client-side encryption. If you need an analogy think ...
8
votes
3answers
3k views

Implementing AES encryption in Java

I'm not a security expert, but while checking over our AES implementation for our flagship product, I've noticed some strange things, like the output length having a relation with the input length and ...
8
votes
2answers
3k views

OpenSSL PBKDF2-HMAC-SHAx proof of concept

I have regrettably been away from C programming for a very long time, so I'd like to get a quick code review of a first proof of concept, before I get too far into adding capabilities, using the ...