Questions tagged [cryptography]
Questions relating to cryptographic topics such as encryption/decryption and hashing. (Not for use with trivial ciphers.)
435
questions
15
votes
3answers
3k 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 ...
13
votes
4answers
3k 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 ...
2
votes
0answers
220 views
XXTEA encryption implemented in modern C++
At the company i work we have a system where an user is presented with a question and some alternatives to choose from. The question and answers are generated at runtime. In order to simplify the ...
4
votes
1answer
270 views
Python Secure Implementation Of AES-256-CTR Using Cryptography.Hazmat
I've implemented a wrapper for AES 256 CTR mode using the cryptography.hazmat module, I am wondering if there are any vulnerabilities in my implementation, specifically about the counter and its ...
5
votes
1answer
268 views
Encrypting credit card data
I need an encryption algorithm that would be secure enough to store credit card data. So it should be reasonably secure.
Here's what I've come up with. I'd appreciate any constructive criticism.
<...
1
vote
1answer
45 views
Small service for hashing and validating passwords, using PBKDF2
As part of a larger authentication/authorization system, I've developed a small .NET Core 3.0 service for hashing passwords using PBKDF2 (with a salt) and validating passwords against a stored hash/...
-1
votes
3answers
49 views
Implement state eraser for NIST DRBG and other crypto primitives using macro
As a spare-time personal project, I'm implementing a set of symmetric-key cryptographic primitives.
One thing I've left vacant for a long time, is the key/state eraser, which I decide to add right ...
4
votes
2answers
194 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. ...
5
votes
1answer
266 views
Educational implementation of SHA256 in Rust
A few weeks ago I decided to have a look at the Rust programming language. After a few standard exercises I chose to try to implement the SHA256 hashing algorithm, because why not.
The algorithm's ...
4
votes
1answer
100 views
Data encryption / decryption on Node.js
I've implemented my first data encryption / decryption methods on Node.js.
Although it might look similar to hundreds of sample implementations available online, I'm curious to get a feedback.
I'm ...
3
votes
1answer
108 views
kryptein cryptography package for Node.js
I have written a cryptography NPM package called kruptein. The code is also hosted on GitHub.
Having used multiple "best practices" with regards to key management, algorithm selection, key size, iv ...
7
votes
2answers
854 views
A simple implementation of the principle of RSA encryption
Inspired by a Numberphile video I made a little program that shows the principles of RSA encryption and decryption. To calculate the keys I used the explanation in this link: rsa public private key ...
3
votes
1answer
120 views
Capsulation solution for byte arrays
In a part of the project, I had to implement a solution for encapsulation of byte arrays. We do use ssh and secure ports for socket connection but I was in need of an extra layer of protection against ...
5
votes
2answers
127 views
PLINQ code analysis in terms of efficiency of cryptographic hashes generation
I have the following code that I wrote in order to find the correct password by generating hashes out of all possible combinations and comparing each of them with the target. I'm trying to make ...
1
vote
1answer
130 views
Expose encrypted serial ID in Elixir
I'm working on a Phoenix/Absinthe application and I thought to expose encrypted sequential IDs instead of UUIDs since these are a bit shorter.
Encryption on Elixir/Erlang seems very hard, so I think I'...
3
votes
1answer
77 views
A Tumbler, or a format-preserving-encryption shuffle
I wanted to implement a simple algorithm for encoding id of entries in a database to avoid:
Storing the UID (unique id) in the ...
2
votes
2answers
160 views
Light Security Local-Machine Password Encryption
I have a program that makes a call to an SQL database. I cannot use SSH to connect to it (as far as I am aware) or any other more secure method, so Java's SQL connector was used. As the connection ...
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 ...
4
votes
2answers
100 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
0answers
91 views
SHA256 implemented in Rust
I just finished making an implementation of a SHA256 hashing function (https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf) in Rust and I was looking for some feedback.
As far as I can tell it ...
4
votes
1answer
92 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 ...
9
votes
1answer
82 views
Fun crypto problem: Exploiting a vulnerable encryption scheme with Python
I came across a question asked here and here on the Crypto Stack Exchange site, and decided to analyze it as a kind of case study. To demonstrate the concept, I wrote a short python script depicting ...
7
votes
2answers
354 views
Finding collisions of the first few bits of a SHA-1 hash
My objective is to find a hash collision of my modified hash function. Assuming my modified hash only outputs the first 36 bits of SHA-1. As we know, SHA-1 is a 160-bit hash value, hence, we only need ...
3
votes
1answer
265 views
File Encryption using pynacl
I need a rather simple file encryptor/decryptor in Python, after some research, I decided to use tye pynacl library reading the file in blocks, writing them back out, and then at the end using Blake2b ...
15
votes
1answer
244 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 ...
3
votes
0answers
56 views
0
votes
1answer
96 views
employing AES algorithm in Java
I have employed an AES algorithm in order to encrypt files within a GUI. I was wondering if my algorithm is secure. Could I change anything to improve it? Is my IV secure and is it producing different ...
4
votes
2answers
164 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:
<...
2
votes
0answers
25 views
RC4 in Sinclair BASIC; Working around one-indexed arrays
This is a program written in Sinclair BASIC (48 BASIC) for the Sinclair ZX Spectrum. It uses a hardcoded key (null right now) as seen in the bottom and outputs a stream of integers generated with RC4. ...
2
votes
1answer
566 views
Cryptographically secure token generation in C#
Is the following a cryptographically secure way to generate a random token? Does it have any of the predictability risks that are theoretically associated with using a GUID as a token?
...
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? ...
2
votes
1answer
114 views
Encrypts using AES GCM for data with limited visibility and long rest
This is the third iteration of my venture on creating an encryption/decryption solution. I asked a question here, which led to this question here, which led to this answer here, which led me to ...
1
vote
1answer
2k views
RSA wrapper written in Kotlin
I've written up a small wrapper for RSA and AES encryption in Kotlin, and I want to make sure I'm not making any glaring mistakes before use it. This is going on a small project with basically no ...
1
vote
1answer
267 views
Encrypts using AES with random initialization vector meant for data with limited visibility and then long rest
I've done some research, reviewed countless SO questions that appeared similar, leading me to endless rabbit holes.
My solution is working, but I don't like it. I want to create a random IV for AES ...
5
votes
2answers
881 views
Python AES-CBC implementation using AES-ECB
I am looking for ways to make this code more "pythonic" and any issues with my implementation. This was designed to solve Crytopal's Challenge 10. This challenge requires recreating the AES-CBC cipher ...
5
votes
1answer
45 views
High performance wrapper for CSPRNG arc4random(3)
This function is a wrapper for arc4random(3), a cryptographic pseudo-random number generator on macOS and BSDs, but you can also get it by installing ...
4
votes
1answer
1k 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?
...
2
votes
0answers
500 views
Python RSA/DSA File Cryptography, Key Generation, Key Protection
I have forked a previous version of my script, critiqued here: Generate public/private keys, encrypt, decrypt, sign, verify
This program allows you to encrypt and decrypt raw files using RSA keys ...
8
votes
3answers
351 views
Generate public/private keys, encrypt, decrypt, sign, verify
My program generates public private keys, encrypts, decrypts, signs and verifies, while using AES for the bulk of the data for speed, and encrypts the random key with RSA. Many operations were chosen ...
1
vote
1answer
500 views
Using encryption/hashing to create a secure login
I am creating a login for an encrypted chat application which retrieves login information from a MySQL database. I have got to the point where I feel pretty confident that (to the best of my knowledge)...
1
vote
1answer
73 views
Encrypt data to be send from service to service
I'm working with another company in a new application for my company. My job right now is to send on demand to the other company the data that they need, ciphering some of it.
I should point out that ...
2
votes
1answer
81 views
Crypto for a funny contest with friends
I am participating in a funny crypto contest with my friends. This time, we raised the bar quite a bit.
The code below is my take for the constraints we set.
Note that on my machine, the code works ...
3
votes
0answers
423 views
Verify OpenSSL RSA signature (PHP) with .NET (VB)
I would like to achieve something I believe is pretty standard:
A) My VB.NET client (ideally targetting Framework 4.0) sends a text string to my Apache/PHP Server via an HTTPS POST request.
B) My ...
6
votes
2answers
403 views
RSA c implementation
This is my first attempt to implement a crypto algorithm.
I am using C and gmp to interact with big numbers.
Here is my code; you can run it after having linked with the ...
5
votes
1answer
150 views
First encryption program
This is the first piece of code that I write that's not just an exercise but a full program I can actually run.
Features:
Generate random letter/number pairs for each "printable" ASCII character
...
2
votes
2answers
83 views
Checking hash and passwords with a wordlist, more efficient
I have done a small code in which with a wordlist (out68.lst) I get the passwords from the hashes in the file 'shadow3'.
...
10
votes
1answer
912 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 ...
7
votes
1answer
233 views
Frequency Analysis & Chi-Squared Test
Following up on my implementation of Cryptopals Challenge 1, this is my solution to Challenge 3.
Single-byte XOR cipher The hex encoded string:
...
1
vote
1answer
95 views
Spring API that performs RSA encryption with exception handling [closed]
I'm creating a rest api using Spring which utilize javax.crypto as library to do some encryption stuff. While everything works well, I'm curious whether the error handling like this is acceptable or ...
3
votes
1answer
989 views
Secure password hashing implementation with salt and pepper
I share below my password hashing implementation with salt and pepper in C#, for your review and feedback. In my implementation methods like ValidatePassword(), ChangePassword() are in the user class.
...