The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
5
votes
2answers
5k views

AES CTR mode using pycrypto

I've implemented CTR mode by myself (only decryption for now), using only AES built-in functions from pycrypto. It means that I'm not supposed to use mode=AES.MODE_CTR. However, I know that using AES....
5
votes
1answer
1k views

Custom password encryption

The point of the program will be to have an file that will hold encrypted passwords which will only be unlocked by the password that encrypted them. I don't plan to use it in any web application/login ...
5
votes
1answer
123 views

T-SQL Pbdfk2 (Rfc2898 SHA2_256) Implementation

Using my previous function as a base I've come up the following: ...
5
votes
1answer
222 views

Parallelizing scrypt key-derivation function

To review my use of multiprocessing, I don't think it is at all necessary to understand the algorithm, but it's the scrypt key-derivation function. This uses ...
5
votes
0answers
3k views

Java AES-256 GCM file encryption

I wrote my first file encryption program, that encrypts a file with AES-256 GCM and stores IV and salt prepended to the file content, so it's likely that I did something worse than possible. I ...
4
votes
5answers
3k views

XOR encryption program in C

I've written a program that encrypts files (or stdin) with a user-specified key from 1 to 255. This "encryption" is very insecure, but still a bit better than ROT13 ...
4
votes
1answer
892 views

Naïve RSA decryption in Python

I am making a code with basic RSA encryption/decryption. My professor wants me to speed up this function but it is already so simple and I am lost. Any ideas? ...
4
votes
2answers
10k views

Encrypting and decrypting passwords in PHP

I am wanting to encrypt a password and decrypt a password using PHP. Is this a safe method? ...
4
votes
3answers
702 views

Simplifying Cryptography Key Generation without Losing Security

I am writing a helper class for encrypting string and other data types. My goal is to make it as easy as possible to use, while still keeping a substantial amount of security. One issue I struggled ...
4
votes
2answers
5k views

One Time Pad algorithm for encryption and decryption

I have written my own one time pad algorithm for encryption and decryption, but I would like to listen to your opinions about its correctness and eventually how could I improve it. My idea was to keep ...
4
votes
3answers
5k views

Cipher decryption and encryption

I'm brand new to C# and I've started to make a cipher decryption program. The code works and runs fine, apart from the odd exception. I'm just looking for ways to improve my code and make more ...
4
votes
2answers
229 views

New MD5 algorithm

Can you please try my algorithm and give comments or feedback about it? ...
4
votes
2answers
5k views

Simple stream cipher encryption/decryption function

This is a Python implementation of a stream cipher encryption algorithm. This implementation originates from the one displayed on the TI-Basic wikidot cryptography page. I am well aware that this ...
4
votes
2answers
2k views

Hashing passwords for a website

I have spent about 2 weeks reading about hashing passwords and website security. As there seems to be many different ways to achieve this, I'm a bit confused as to whether my code is secure. Can ...
4
votes
2answers
66 views

C# Cryptography Interface

C# lacks a common off-the-shelf encryption and decryption interface for dependency injection. Nearly every codebase I've ever opened has a couple of extension methods for hashing strings and so on. ...
4
votes
1answer
67 views

PRBHA-10: A hashing algorithm in Python

So I've been working on a simple little hashing algorithm for Python that I like to call PRBHA-10 for short, or Pseudo-Random-Based Hash Algorithm. This is a hash algorithm in Python that is meant to ...
4
votes
2answers
88 views

F# wrapper to generate SHA256 signature for a file

I've created the following module to allow me to generate a SHA256 signature for a file. (In real life this is used to verify an image file hasn't been amended). The cut down code looks like this: <...
4
votes
3answers
521 views

Is this a secure way to hash a password?

I'm implementing a login system on app engine (I have to, so please don't tell me to use the User service, or an other way to delegate authentication), and I'm wondering whether this setup is secure. ...
4
votes
2answers
135 views

File's encryption tool in terminal

I've created a wrapper for the SimpleCrypt library that allows to easily encrypt/decrypt a string. The application is used this : ...
4
votes
2answers
1k views

Simple hashing and salting algorithm

I have devised what I feel to be a simple hash/salting algo for Java, and am looking for some feedback from people more skilled than myself. Please find below my code; ...
4
votes
1answer
212 views

Truncate 160-bit output from SHA-1 to 64-bit uint64_t

I'd like to truncate 160-bit output from SHA-1 to receive a (weaker) 64-bit digest. It has been a while since I did the type of low-level C pointer arithmetic in the but-last line. Could you please ...
4
votes
2answers
1k views

Cookie encryption library

Recently I needed to save session state in cookies, instead of server side. I looked around and didn't see anything similar, so I decided to write something to handle the encryption, decryption, and ...
4
votes
2answers
190 views

Basic Crypto for .NET

Please tell me if I'm doing this right, and what else is needed to make this hardened. It seems like it's too simple, like there's almost nothing I'm actually doing. For example, there are 4 or 5 ...
4
votes
1answer
1k views

Rijndael compression/encryption class

Out of personal interest and as a learning exercise I've written a C# class (.NET 4) to perform encryption/decryption of a file along with some compression upon encryption. Most of my understanding of ...
4
votes
2answers
3k views

AES and RSA using javax.crypto

So I am assuming that I did something wrong, and my AES and RSA encryption and decryption classes are insecure. I plan on using them for a larger project, and want to make sure I didn't completely ...
4
votes
1answer
1k views

Python PBKDF2 using core modules

I'm trying to implement pbkdf2 in Python 2.7/3.4 without needing the pbkdf2 module. (I'm also trying to avoid using classes.) Any insight would be appreciated: ...
4
votes
1answer
654 views

Simple password dictionary attack script

This is my simple Perl script implement password dictionary attacking, encryption algorithm SHA1 with different length. It takes 2 arguments as input: first argument is password dictionary file path, ...
4
votes
1answer
117 views

(Final)Simple Decryptor/Encryptor

This is my final version of my simpel Decrypter/Encryptor called Dencryptor. This is one of my first Python projects and I think it turned out pretty good. I am using a Caesar cipher right now and I ...
4
votes
1answer
639 views

Tiny Encryption Algorithm implementation in C

I was just looking for a general feedback about this code, which encrypts a file with the Tiny Encryption Algorithm. I'm currently studying C, and I wanted to know if there was anything I could ...
4
votes
2answers
1k views

Matasano CryptoPals Problem 8: Detecting ECB encryption

For the Matasano CryptoPals Challenges Set 1 Problem 8, which states: In this file are a bunch of hex-encoded ciphertexts. One of them has been encrypted with ECB. Detect it. ...
4
votes
1answer
2k views

Polyalphabetic cipher

I am trying to write the simplest to undestand code possible, each function has documentation and examples and I tried to use the best style possible. ...
4
votes
1answer
3k views

Is this password hashing acceptable for a custom MembershipProvider?

I'm creating a custom MembershipProvider for an ASP.NET MVC5 application and am wanting to know if this code is acceptable for creating hashed and salted passwords. ...
4
votes
1answer
651 views

Reducing repetitive Android code

How can I reduce the amount of repetitive code in my Android app? A lot of the code seems to be doing the same thing twice. I think that there is a more compact way to do this. What are some ways ...
4
votes
1answer
2k views

Am I using crypt and mcrypt well in this simple encryption class?

These days I read a lot here on SO about password hashing and data encryption. It's a real mess, I mean, deciding what the best practice is. I need a very simple class that can be reused anywhere and ...
4
votes
1answer
1k views

Cryptographic key exchange

I initially posted this on StackOverflow, and was redirected here. I have been playing around with Bouncy Castle (Java) for the last few days, and I've reached the point where I believe I can securely ...
4
votes
2answers
52 views

File encoder/decoder in Nim

I wrote a simple program to encode a local text file with password and decode it back. There is one text file and it is either encoded with a password or is in plain text. I had a version in Python ...
4
votes
1answer
315 views

Plain Java Encryption with Integrity and Authenticity

I spent quite some time and wrote a single class for the purpose of encrypting/decrypting plaintext bytes with a passphrase. The goal is to not have any further dependencies apart from ...
4
votes
2answers
104 views

Sign an EC2/S3 URL Version 3

From the previous 2 versions: Sign an EC2/S3 URL Version 2 I fixed the comments from the previous version. Most of the code remains the same (so I have split out the new code for review). The main ...
4
votes
2answers
173 views

Sign an EC2/S3 URL

The other day I found myself trying to walk through the instructions for signing an S3 URL. http://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html Not as trivial as the ...
4
votes
2answers
545 views

Generate a Bitcoin Address and the Wif from a phrase

Is there a way to speed up my Python code? ...
4
votes
1answer
103 views

Rvalue copy and and assignment for secure array class [closed]

I have a C++03 library with lots of classes. I'm interested in trying to take advantage of Rvalues and move semantics under C++11 for two or three critical classes. Once of the critical classes is a <...
4
votes
1answer
6k views

Encrypting data on client side and passing it to server side

I'm passing the data to PHP server side which will use the information later as this: ...
4
votes
1answer
3k views

How to optimize this Playfair encryption?

For the implementation of the Playfair encryption I needed a custom struct called Cell. This is because I not only need an array of characters I also want to get Elements in a matrix based on their "...
4
votes
1answer
15k views

Playfair Cipher in C++

I have been working on a Playfair Cipher in C++ for a final Project in a Cryptography class. I was hoping for some feedback on the project so far. I recently got a job programming before I've even ...
4
votes
1answer
2k views

A random relative prime number based on the modulus

I am implementing RSA in java using BigInteger and I have a method to return a random relative prime number based on the modulus m. The method looks like this: ...
4
votes
1answer
595 views

Finding a cryptoarithmetic solution

This code is intended to find all possible solutions to a cryptoarithmetic problem. The description of the problem I was trying to solve is here: In cryptoarithmetic problems, we are given a ...
4
votes
1answer
148 views

HKDF and compare constant time in Rust

I have implemented HKDF in Rust, which passes all test vectors from RFC 5869, using HKDF with HMAC-SHA256. I also have a function to compare byte arrays in constant time, which I hope someone could ...
4
votes
1answer
90 views

Is it proper to use nested loops a lot in python?

I have a project and I am trying to do a complex cryptographic method. Is it normal to use nested loops a lot? Or Did I miss something? I intend to create a method which tries all strings to find ...
4
votes
1answer
304 views

AES Encryption/Decryption

Where I currently work I'm tasked with writing a good encryption and decryption code which will have DEK as well as KEK. Haven't started on KEK yet. I have already told them, that we need expert help, ...
4
votes
1answer
94 views

T-SQL Secure String Comparison

The previous version of my function was scalar-valued and employed a WHILE loop to do the comparison, this is SLOW. This new version is tabled-valued and uses a typical tally table in place of the ...