Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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,597
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.4k
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
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
23 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
  • 66.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
  • 33.7k
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
  • 8,917
17 votes
Accepted

Homemade cyraz encryption algorithm

You are using in your code some non-standard loops. for (int i = 1; i <= streamFooter.Length; ++i) There should be a comment explaining why this loop is ...
t3chb0t's user avatar
  • 44.3k
16 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
  • 9,844
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 <...
Harith's user avatar
  • 7,174
15 votes

AES Implementation in C++

Interface Design: ...
Martin York's user avatar
  • 95.2k
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.7k
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

Baconian Cipher Python Implementation

Bug Letters J & K, U & W, and V & X have the same pattern. This is not what the specification says: either I & J and U & V shares the same pattern, or none of the letters do. Style ...
301_Moved_Permanently's user avatar
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 - Reinstate Monica'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
  • 43.4k
13 votes

One Time Pad in Python

Here are some of your functions translated to be more pythonic: Context managers mean never having to say your closed(): We can recast thse 2 functions (including fixing the bug of not closing the ...
Stephen Rauch's user avatar
13 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.3k
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.3k
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
  • 41k
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,716
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.3k
13 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
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
  • 43.4k
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,157
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
  • 76.2k
11 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 - Reinstate Monica's user avatar
11 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 ...
Quitting Due To Antisemitism's user avatar
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
  • 76.2k

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