Skip to main content
31 votes

Encryption algorithm for an app

No. This is just a worse Caeser cypher. steps to break: Convert each string to an int in the output Subtract everything from the min output value - ord('A') ...
Oscar Smith's user avatar
  • 3,717
30 votes
Accepted

A Caesar cipher in Python3

You say you're new to Python. Well, that's ok. And a Caeser Cipher is a good place to start since it's complex enough for an absolute beginner while easy enough to understand what goes on, why and ...
Mast's user avatar
  • 13.8k
27 votes

AES Implementation in C++

Since there are only three valid key sizes for AES, it makes sense to not even let the AES class be instantiated with any uint16 value. I would introduce an enum ...
Millie Smith's user avatar
24 votes
Accepted

Fast symmetric key cryptography class

Here are a number of things you could do to improve the code. Separate interface from implementation The interface goes into a header file and the implementation (that is, everything that actually ...
Edward's user avatar
  • 67.2k
23 votes
Accepted

AES Implementation in C++

I'm looking to improve the code to make it not "DIY-crypto-bad", if at all possible I work in security. This is not my area, but I have a non-zero amount of knowledge on implementing secure ...
BoppreH's user avatar
  • 346
18 votes

Naïve RSA decryption in Python

Simple does not mean fast, so you cannot judge performance based on how simple the implementation looks. Usually the most efficient way to perform a non-trivial task is not also the simplest way to do ...
user555045's user avatar
  • 12.4k
18 votes
Accepted

Employing 3DES algorithm in Java

It's kind of secure, but it uses older algorithms. Although Benjamin correctly identifies 3DES, I would not call 3 key triple DES "broken". It still delivers a security of about 112 bits which nobody ...
Maarten Bodewes's user avatar
18 votes

A Caesar cipher in Python3

I hate to provide an "answer only" code review, but I'd like to expand upon Mast's "Python comes batteries included" point: Python comes with a str.translate, ...
AJNeufeld's user avatar
  • 35.3k
18 votes

A randomized encryption program

First, congratulations! Being able to produce something usable with another person is an incredibly important skill, and especially in programming. Please don't worry about the amount of suggestions ...
l0b0's user avatar
  • 9,117
16 votes
Accepted

SHA-256 Implementation

The functions that are not used outside of a translation unit should be defined as having internal linkage: Everything except sha256() should be defined with the <...
Madagascar's user avatar
  • 10.1k
16 votes
Accepted

Python secrets command-line tool

UX for the CLI some commands you can run with this tool: sct -tokenhex 8, ... That's nice. But wouldn't you like to also expose ...
J_H's user avatar
  • 42.2k
15 votes

AES Implementation in C++

Interface Design: ...
Loki Astari's user avatar
  • 97.7k
15 votes
Accepted

Cryptographically Secure Password Generation in C

Overall, this is pretty well written. It's very easy to read and understand. I especially like that you annotated the usage() function with ...
user1118321's user avatar
  • 11.9k
15 votes

SHA-256 Implementation

On top of what Harith has already posted: Your program isn't scalable Hashing files is intended to work on files of any size. Your program implicitly assumes it will only be used with files that fit ...
ShadowRanger's user avatar
14 votes
Accepted

RSA algorithm implementation in Python 3

I think your Modular Inverse implementation is slow. We can apply this Extended GCD algorithm recursive implementation which shows quite a dramatic speed improvement (at least on my machine): ...
alecxe's user avatar
  • 17.5k
14 votes
Accepted

Implementation of the Jacobi Symbol in C

I am only looking for some feedback on my coding style. Formatting is good. I hope it is auto formatted. Respect the presentation width Rather than oblige a horizontal scroll bar, auto format to a ...
chux's user avatar
  • 36.4k
14 votes

Fast symmetric key cryptography class

Please do not roll your own encryption outside of an academic context. If you would like a fast algorithm that can be easily implemented in C/C++ take a look at ChaCha or Salsa. Runs great on most ...
foreverska's user avatar
14 votes

Secrets management, operational security, keeping API tokens hidden while streaming

Your main is a classic arrow anti-pattern. You can use guard clauses to make the code flat and easier to understand. Bare excepts are normally not a good idea. Why ...
Peilonrayz's user avatar
  • 44.6k
13 votes

AES Implementation in C++

I think the header could be trimmed down a lot. The constant tables belong in the implementation file since they are not needed for the definition of the class. Since the AES class does not hold any ...
Roland Illig's user avatar
  • 21.9k
13 votes
Accepted

Self-contained SHA-256 implementation in C

Nice implementation. Good attention to shift types. Use bool. Various members, functions are used only in a boolean fashion. Use ...
chux's user avatar
  • 36.4k
13 votes

Encryption algorithm for an app

In addition to Oscar Smith's answer why this code is not secure, here are a few nitpicks on your code itself: While it is legal to end a line with ; in Python, it ...
Graipher's user avatar
  • 41.7k
13 votes
Accepted

Data encryption with python

That seems like a very long method to splice and put together the string every even set of characters. You are essentially trying to build a square matrix using the characters from the given string. ...
hjpotter92's user avatar
  • 8,921
13 votes

Employing 3DES algorithm in Java

No, it's not secure. Your code is using Random instead of SecureRandom, which limits the entropy of the salt to 48 bits. In ...
Roland Illig's user avatar
  • 21.9k
12 votes

Data encryption with python

One of your lines of code is horribly cryptic. I think it's so bad it's worthy of it's own answer. ...
Peilonrayz's user avatar
  • 44.6k
12 votes

Fast symmetric key cryptography class

Regarding the cryptographic algorithm only: Important observations This is equivalent to an XOR cipher with a repeating 256-byte key. The key16 stuff adds no security. The randKey stuff adds no ...
Stack Exchange Broke The Law's user avatar
12 votes

A randomized encryption program

In addition to the great answer already provided by l0b0, a few comments. 1. code structure Some blocks could be extracted to functions. For instance, the following block inside ...
Ron Klein's user avatar
  • 1,227
11 votes
Accepted

ECDH implementation in python

You can easily replace your Point class with namedtuple here. In fact the docs itself contain an example related to a ...
Ashwini Chaudhary's user avatar
11 votes

AES Implementation in C++

You don't show us the BlockCipher base class, but it appears that it imposes a terrible interface on us: ...
Toby Speight's user avatar
  • 88.3k
10 votes

MD5 implementation in C++11

First impressions The code seems very clean and tidy. As far as I can tell, you're including exactly the required headers - no more, and no less. There's generally good use of ...
Toby Speight's user avatar
  • 88.3k
10 votes

Secrets management, operational security, keeping API tokens hidden while streaming

...
AJNeufeld's user avatar
  • 35.3k

Only top scored, non community-wiki answers of a minimum length are eligible